RYU_Sho_Coup = {

	RYU_start_the_coup = {

		available = {
			OR = {
				has_country_flag = RYU_ENG_support
				has_country_flag = RYU_USA_support
				has_country_flag = RYU_FRA_support
			}
		}

		visible = {
			TAG = RYU
		}
		allowed = { tag = RYU }
		
		fire_only_once = yes

		complete_effect = {
			#country_event = { id = RYU_sho_coup.1 }
			set_country_flag = RYU_started_the_coup_flag
		}
		
		ai_will_do = {
			base = 1
			modifier = {
				factor = 10
				has_country_flag = RYU_ENG_support
				has_country_flag = RYU_USA_support
				has_country_flag = RYU_FRA_support
			}
			modifier = {
				factor = 2
				has_country_flag = RYU_ENG_support
				has_country_flag = RYU_USA_support
				NOT = { has_country_flag = RYU_FRA_support }
				FRA = { NOT = { has_country_flag = FRA_has_colonial_ambitions } }
				NOT = { has_global_flag = eoanb_flag_sow_ENG_FRA_cooperate }
			}
			modifier = {
				factor = 5
				has_country_flag = RYU_ENG_support
				has_country_flag = RYU_FRA_support
				NOT = { has_country_flag = RYU_USA_support }
				has_global_flag = ACW_American_Civil_War
			}
		}
	}
	
	RYU_eng_coup_support = {

		available = {
			custom_trigger_tooltip = {
				tooltip = RYU_prosperity_mechanic_greater_than_5
					check_variable = {
					ryu_prosperity_mechanic > 4
				}
			}
		}
		
		fire_only_once = yes

		visible = {
			TAG = RYU
			NOT = { has_country_flag = RYU_started_the_coup_flag }
		}
		allowed = { tag = RYU }


		complete_effect = {
			ENG = { country_event = { id = RYU_bernard_bettelheim_success.7 days = 12 } }
			custom_effect_tooltip = RYU_prosperity_mechanic_minus_5
			add_to_variable = {
				var = ryu_prosperity_mechanic
				value = -5
			}
		}
		
		ai_will_do = {
			base = 100
		}
	}

	RYU_usa_coup_support = {

		available = {
			custom_trigger_tooltip = {
				tooltip = RYU_prosperity_mechanic_greater_than_5
					check_variable = {
					ryu_prosperity_mechanic > 4
				}
			}
			OR = {
				has_global_flag = ACW_American_Civil_War_Avoided
				NOT = { has_global_flag = ACW_American_Civil_War_Happened }
			}
			#if = {
			#	limit = {
			#		USA = { has_country_flag = USAPanic_Of_1857 }
			#	}
			#	custom_trigger_tooltip = {
			#		tooltip = RYU_usa_recovered_from_panic
			#		USA = { has_completed_focus = USA_panic_recovery }
			#	}
			#}
		}
		
		fire_only_once = yes

		visible = {
			TAG = RYU
			NOT = { has_country_flag = RYU_started_the_coup_flag }
		}
		allowed = { tag = RYU }


		complete_effect = {
			USA = { country_event = { id = ryukyu.15 days = 12 } }
			custom_effect_tooltip = RYU_prosperity_mechanic_minus_5
			add_to_variable = {
				var = ryu_prosperity_mechanic
				value = -5
			}
		}
		
		ai_will_do = {
			base = 100
		}
	}
	
	RYU_french_coup_support = {

		available = {
			custom_trigger_tooltip = {
				tooltip = RYU_prosperity_mechanic_greater_than_5
					check_variable = {
					ryu_prosperity_mechanic > 4
				}
			}
			FRA = { has_country_flag = FRA_has_colonial_ambitions }
			has_global_flag = eoanb_flag_sow_ENG_FRA_cooperate
		}
		
		fire_only_once = yes

		visible = {
			TAG = RYU
			NOT = { has_country_flag = RYU_started_the_coup_flag }
		}
		allowed = { tag = RYU }


		complete_effect = {
			FRA = { country_event = { id = ryukyu.16 days = 12 } }
			custom_effect_tooltip = RYU_prosperity_mechanic_minus_5
			add_to_variable = {
				var = ryu_prosperity_mechanic
				value = -5
			}
		}
		
		ai_will_do = {
			base = 100
		}
	}
}


RYU_Prosperity_Mechanic = {

	RYU_usa_industrial_investment = {

		available = {
			always = no
		}

		visible = {
			always = no
			
		}
		allowed = { tag = RYU }


		complete_effect = {
		   
		}
		days_remove = 720
		
		modifier = {
			political_power_cost = 0.15
        }
		
		fire_only_once = yes
		
		remove_effect = {
           capital_scope = {
				add_extra_state_shared_building_slots = 5
				add_building_construction = {
					type = infrastructure
					level = 4
					instant_build = yes
				}
		   }
		   custom_effect_tooltip = EDC_afr.6.t
		   hidden_effect = {
				country_event = { id = EDC_afr.6 hours = 1 } 
		   }
        }
		
		ai_will_do = {
			factor = 1000
			modifier = {
				factor = 0
				has_political_power < 50
			}
		}
	}

	RYU_french_industrial_investment = {

		available = {
			always = no
		}

		visible = {
			always = no
			
		}
		allowed = { tag = RYU }


		complete_effect = {
		   
		}
		days_remove = 720
		
		modifier = {
			political_power_cost = 0.15
        }
		
		fire_only_once = yes
		
		remove_effect = {
           capital_scope = {
				add_extra_state_shared_building_slots = 2
				add_building_construction = {
					type = dockyard
					level = 2
					instant_build = yes
				}
				add_building_construction = {
					type = naval_base
					level = 2
					province = 11932
					instant_build = yes
				}
		   }
		   custom_effect_tooltip = EDC_afr.6.t
		   hidden_effect = {
				country_event = { id = EDC_afr.6 hours = 1 } 
		   }
        }
		
		ai_will_do = {
			factor = 1000
			modifier = {
				factor = 0
				has_political_power < 50
			}
		}
	}

	RYU_british_industrial_investment = {

		available = {
			always = no
		}

		visible = {
			always = no
			
		}
		allowed = { tag = RYU }


		complete_effect = {
		   
		}
		days_remove = 720
		
		modifier = {
			political_power_cost = 0.15
        }
		
		fire_only_once = yes
		
		remove_effect = {
           capital_scope = {
				add_extra_state_shared_building_slots = 3
				add_building_construction = {
					type = industrial_complex
					level = 2
					instant_build = yes
				}
				add_building_construction = {
					type = industrial_complex
					level = 1
					instant_build = yes
				}
		   }
		   custom_effect_tooltip = EDC_afr.6.t
		   hidden_effect = {
				country_event = { id = EDC_afr.6 hours = 1 } 
		   }
        }
		
		ai_will_do = {
			factor = 1000
			modifier = {
				factor = 0
				has_political_power < 50
			}
		}
	}
	
	RYU_build_dockyard = {

		available = {
			custom_trigger_tooltip = {
				tooltip = RYU_dockyard_forign_help_tooltip
				has_country_flag = RYU_dockyard_forign_help
			}
			custom_trigger_tooltip = {
				tooltip = RYU_prosperity_mechanic_greater_than_15
				check_variable = {
					ryu_prosperity_mechanic > 14
				}
			}
			custom_trigger_tooltip = {
				tooltip = afr_prosperity_mechanic_construction
				check_variable = { afr_reforming_regional_power_construction_in_progress < 1 }
			}
		}

		visible = {
			TAG = RYU
			
		}
		allowed = { tag = RYU }


		complete_effect = {
			add_political_power = -50
			custom_effect_tooltip = RYU_prosperity_mechanic_minus_15
			add_to_variable = {
				var = ryu_prosperity_mechanic
				value = -15
			}
			add_to_variable = { var = afr_reforming_regional_power_construction_in_progress value = 1 }
			if = {
				limit = {
					has_country_flag = RYU_ENG_dockyard_forign_help
				}
				ENG = { country_event = { id = RYU_dockyard_construction.1 days = 12 } }
			}
		}
		days_remove = 360
		
		cost = 50
		
		modifier = {
			political_power_cost = 0.5
        }
		
		fire_only_once = yes
		
		remove_effect = {
            random_owned_controlled_state = {
				limit = { 
					is_core_of = ROOT 
					is_coastal = yes
				}
				add_extra_state_shared_building_slots = 1
				add_building_construction = {
					type = dockyard
					level = 1
					instant_build = yes
				}
		   }
		   custom_effect_tooltip = EDC_afr.6.t
		   hidden_effect = {
				country_event = { id = EDC_afr.6 hours = 1 } 
		   }
		   add_to_variable = { var = afr_reforming_regional_power_construction_in_progress value = -1 }
        }
		
		ai_will_do = {
			factor = 1000
			modifier = {
				factor = 0
				has_political_power < 50
			}
		}
	}

	RYU_build_farm = {

		available = {
			if = {
				limit = {
					any_owned_state = {
						is_core_of = ROOT
						farm > 6 
					}
					NOT = { has_tech = threshing_machine }
				}
				custom_trigger_tooltip = {
					tooltip = RYU_prosperity_mechanic_greater_than_5
						check_variable = {
						ryu_prosperity_mechanic > 4
					}
				}
				custom_trigger_tooltip = {
					tooltip = Ocenaia_farm_less_than_7
					any_owned_state = { 
						farm < 7 
						is_core_of = ROOT
					}
				}
				custom_trigger_tooltip = {
					tooltip = Ocenaia_farm_research_threshing_machine
					has_tech = threshing_machine
				}
			}
			if = {
				limit = {
					has_tech = threshing_machine
				}
				custom_trigger_tooltip = {
					tooltip = RYU_prosperity_mechanic_greater_than_5
						check_variable = {
						ryu_prosperity_mechanic > 4
					}
				}
				custom_trigger_tooltip = {
					tooltip = Ocenaia_farm_less_than_10
					any_owned_state = { 
						farm < 10 
						is_core_of = ROOT
					}
				}
			}
			if = {
				limit = {
					any_owned_state = {
						is_core_of = ROOT
						farm < 7 
					}
					NOT = { has_tech = threshing_machine }
				}
				custom_trigger_tooltip = {
					tooltip = RYU_prosperity_mechanic_greater_than_5
						check_variable = {
						ryu_prosperity_mechanic > 4
					}
				}
				custom_trigger_tooltip = {
					tooltip = Ocenaia_farm_less_than_7
					any_owned_state = { 
						farm < 7 
						is_core_of = ROOT
					}
				}
			}
			custom_trigger_tooltip = {
				tooltip = Ocenaia_has_infrastructure_to_support_new_buildings
				any_owned_state = { 
					 
					is_core_of = ROOT
				}
			}
			custom_trigger_tooltip = {
				tooltip = afr_prosperity_mechanic_construction
				check_variable = { afr_reforming_regional_power_construction_in_progress < 1 }
			}
		}

		visible = {
			TAG = RYU
			
		}
		allowed = { tag = RYU }


		complete_effect = {
			add_political_power = -25
			custom_effect_tooltip = RYU_prosperity_mechanic_minus_5
			add_to_variable = {
				var = ryu_prosperity_mechanic
				value = -5
			}
			add_to_variable = { var = afr_reforming_regional_power_construction_in_progress value = 1 }
		}
		
		days_remove = 550
		
		cost = 25
		
		modifier = {
			political_power_cost = 0.5
        }
		
		
		remove_effect = {
            random_owned_controlled_state = {
				limit = { 
					is_core_of = ROOT 
					OR = {
						AND = {
							ROOT = { NOT = { has_tech = threshing_machine } }
							farm < 7
						}
						AND = {
							ROOT = { has_tech = threshing_machine }
							farm < 10
						}
					}
					
				}
				hidden_effect = {
					add_to_variable = { Oceania_extra_state_shared_building_slots = 1 }
				}
				add_extra_state_shared_building_slots = 1
				add_building_construction = {
					type = farm
					level = 1
					instant_build = yes
				}
				add_manpower = 5000
		   }
		   add_to_variable = { var = afr_reforming_regional_power_construction_in_progress value = -1 }
        }
		
		ai_will_do = {
			factor = 10
			modifier = {
				factor = 0
				has_political_power < 50
			}
		}
	}
	
	RYU_build_cotton_farm = {

		available = {
			if = {
				limit = {
					any_owned_state = {
						is_core_of = ROOT
						cotton_farm > 6 
					}
					NOT = { has_tech = threshing_machine }
				}
				custom_trigger_tooltip = {
					tooltip = RYU_prosperity_mechanic_greater_than_5
						check_variable = {
						ryu_prosperity_mechanic > 4
					}
				}
				custom_trigger_tooltip = {
					tooltip = Ocenaia_cotton_farm_less_than_7
					any_state = { 
						cotton_farm < 7 
						is_core_of = ROOT
					}
				}
				custom_trigger_tooltip = {
					tooltip = Ocenaia_cotton_farm_research_threshing_machine
					has_tech = threshing_machine
				}
			}
			if = {
				limit = {
					has_tech = threshing_machine
				}
				custom_trigger_tooltip = {
					tooltip = RYU_prosperity_mechanic_greater_than_5
						check_variable = {
						ryu_prosperity_mechanic > 4
					}
				}
				custom_trigger_tooltip = {
					tooltip = Ocenaia_cotton_farm_less_than_10
					any_state = { 
						cotton_farm < 10 
						is_core_of = ROOT
					}
				}
			}
			if = {
				limit = {
					any_owned_state = {
						is_core_of = ROOT
						cotton_farm < 7 
					}
					NOT = { has_tech = threshing_machine }
				}
				custom_trigger_tooltip = {
					tooltip = RYU_prosperity_mechanic_greater_than_5
						check_variable = {
						ryu_prosperity_mechanic > 4
					}
				}
				custom_trigger_tooltip = {
					tooltip = Ocenaia_cotton_farm_less_than_7
					any_state = { 
						cotton_farm < 7 
						is_core_of = ROOT
					}
				}
			}
			custom_trigger_tooltip = {
				tooltip = Ocenaia_has_infrastructure_to_support_new_buildings
				any_owned_state = { 
					 
					is_core_of = ROOT
				}
			}
			custom_trigger_tooltip = {
				tooltip = afr_prosperity_mechanic_construction
				check_variable = { afr_reforming_regional_power_construction_in_progress < 1 }
			}
		}

		visible = {
			TAG = RYU
		}
		allowed = { tag = RYU }

		complete_effect = {
			add_political_power = -50
			custom_effect_tooltip = RYU_prosperity_mechanic_minus_5
			add_to_variable = {
				var = ryu_prosperity_mechanic
				value = -5
			}
			add_to_variable = { var = afr_reforming_regional_power_construction_in_progress value = 1 }
		}
		
		days_remove = 720
		
		cost = 50
		
		modifier = {
			political_power_cost = 0.5
        }
		
		remove_effect = {
			random_owned_controlled_state ={
				limit = {
					is_core_of = ROOT 
					OR = {
						AND = {
							ROOT = { NOT = { has_tech = threshing_machine } }
							cotton_farm < 7
						}
						AND = {
							ROOT = { has_tech = threshing_machine }
							cotton_farm < 10
						}
					}
					
				}
				hidden_effect = {
					add_to_variable = { Oceania_extra_state_shared_building_slots = 1 }
				}
				add_extra_state_shared_building_slots = 1
				add_building_construction = {
					type = cotton_farm
					level = 1
					instant_build = yes
				}
		   }
		   add_to_variable = { var = afr_reforming_regional_power_construction_in_progress value = -1 }
        }
		
		ai_will_do = {
			factor = 10
			modifier = {
				factor = 0
				has_political_power < 50
			}
		}
	}
	
	RYU_prosperity_mechanic_clear_development = {

		available = {
			#custom_trigger_tooltip = {
			#	tooltip = afr_prosperity_mechanic_greater_than_10
			#		check_variable = {
			#		afr_prosperity_mechanic_value > 9
			#	}
			#}
			custom_trigger_tooltip = {
				tooltip = Ocenaia_has_insufficient_infrastructure_to_support_new_buildings
				all_owned_state = {
					if = {
						limit = {
							is_core_of = ROOT
						}
						is_core_of = ROOT
						 
					}
				}
			}
			custom_trigger_tooltip = {
				tooltip = Ocenaia_has_infrastructure_to_support_clearing_land
				any_owned_state = { 
					 
					is_core_of = ROOT
				}
			}
			custom_trigger_tooltip = {
				tooltip = afr_prosperity_mechanic_construction
				NOT = { has_country_flag = Oceania_prosperity_mechanic_construction_flag }
			}
		}

		visible = {
			all_owned_state = {
				if = {
					limit = {
						is_core_of = ROOT
					}
					is_core_of = ROOT
					 
				}
			}
			TAG = RYU
		}
		allowed = { tag = RYU }

		complete_effect = {
			add_political_power = -15
			#custom_effect_tooltip = afr_prosperity_mechanic_minus_10
			#add_to_variable = {
			#	var = afr_prosperity_mechanic_value
			#	value = -10
			#}
			set_country_flag = Oceania_prosperity_mechanic_construction_flag
		}
		
		days_remove = 30
		
		modifier = {
			political_power_cost = 0.1
        }
		
		
		remove_effect = {
			hidden_effect = {
				random_owned_controlled_state = {
					limit = {
						is_core_of = ROOT 
						
					}
					add_to_variable = { Oceania_extra_state_shared_building_slots = -1 }
					add_extra_state_shared_building_slots = -1
				}
			}
			custom_effect_tooltip = Oceania_infrastructure_for_clearing_building_slots_tooltip
			clr_country_flag = Oceania_prosperity_mechanic_construction_flag
        }
		
		ai_will_do = {
			factor = 10
		}
	}
	
}
			
				
	