on_actions = {
	on_startup = {
		effect = {
			every_country = {
				limit = {
					OR = {
						original_tag = CHI
						original_tag = PRC
						original_tag = GXC
						original_tag = YUN
						original_tag = SHX
						original_tag = XSM
						original_tag = SIK
						original_tag = TNG
					}
				}
				add_to_array = { global.rising_sun_chi_countries = THIS }
			}
		}
		effect = {
			every_country = {
				set_country_flag = friend_for_gibraltar
			}
			every_country = {
				set_country_flag = friend_for_bosphorus
			}
			every_country = {
				set_country_flag = friend_for_dardanelles
			}
		}
	}
	#STRAIT 
	on_daily = {
		effect = {
			every_country = {
				limit = {
					has_country_flag = friend_for_gibraltar
				}
				clr_country_flag = friend_for_gibraltar
			}
			every_country = {
				limit = {
					has_country_flag = friend_for_bosphorus
				}
				clr_country_flag = friend_for_bosphorus
			}
			every_country = {
				limit = {
					has_country_flag = friend_for_dardanelles
				}
				clr_country_flag = friend_for_dardanelles
			}
			if = {
				limit = { 
					any_other_country = {			#those who control Gibraltar determine whose strait it is. Fair? Maybe not entirely
					controls_state = 118
					NOT = {
						has_war_with = ROOT
					}
				}
				OR = {
					118 = { #This so countries allied to the controller of the Gibraltar can cross them. 					#perhaps buffing the importance of taking Gibraltar in such way?
						controller = { 
							OR = {
								is_in_faction_with = ROOT 
								ROOT = { has_military_access_to = PREV }
							}
						}
					}
					ROOT = { #So the controller can cross their own strait 
						AND = {
							controls_province = 4135
							controls_province = 9945
						}
					}
					AND = {	#only for Spain, nobody else
						original_tag = SPR
						any_other_country = {
							original_tag = SPR
							controls_state = 290
						}
						SPR_scw_in_progress = yes		#sanity condition
					}
				}
				}
				set_country_flag = friend_for_gibraltar
			}
			if = { 
				limit = { 
					OR = { 
						AND = { #Before Montreux Convention, everyone treated as "Friend" as long as Turkey is not at war with them and they control the Bosphorus 
							TUR = { 
								NOT = { has_completed_focus = TUR_the_montreux_convention }  
								controls_state = 797
								NOT = { has_country_flag = TUR_strait_compromise_set }
							}
							NOT = { has_war_with = TUR }  	
						}
						AND = { #R56 addition, access defaulted when the Turkey backed down in Montreux, while the above conditions should be maintained
							TUR = { 
								has_completed_focus = TUR_the_montreux_convention
								controls_state = 797
								797 = {
									is_demilitarized_zone = yes
								}
								NOT = { has_country_flag = TUR_strait_compromise_set }
							}
							NOT = { has_war_with = TUR }  	
						}
						AND = { #Bosphorus Compromise. As long as Turkey controls the Bosphorus and they're not at war with them, any country that owns a state bordering the Black Sea is treated as a "Friend"
							TUR = {
								controls_state = 797
								has_country_flag = TUR_strait_compromise_set
							}
							NOT = { has_war_with = TUR }  	
							TUR_owns_state_in_black_sea = yes
						}
						AND = { #R56 addition, vanilla forgot to implement this global flag used in Turkey's ft
							TUR = {
								controls_state = 797
							}
							NOT = { has_war_with = TUR }  	
							has_country_flag = TUR_gets_strait_access
						}
						797 = { #This so countries allied to the controller of the Bosphorus can cross it. 
							controller = {
								OR = {
									is_in_faction_with = ROOT 
									ROOT = { has_military_access_to = PREV }
									is_subject_of = ROOT
								}
							}
						}
						ROOT = { #So the controller can cross their own strait
							controls_state = 797
						}
					}
				}
				set_country_flag = friend_for_bosphorus
			}
			if = { 
				limit = { 
					OR = { 
						AND = { #Before Montreux Convention, everyone treated as "Friend" as long as Turkey is not at war with them and they control The Dardanelles provinces
							TUR = { 
								NOT = { has_completed_focus = TUR_the_montreux_convention }  
								controls_province = 6864
								controls_province = 922				
								NOT = { has_country_flag = TUR_strait_compromise_set }
							}
							NOT = { has_war_with = TUR }  	
						}
						AND = { #R56 addition, access defaulted when the Turkey backed down in Montreux, while the above conditions should be maintained
							TUR = { 
								has_completed_focus = TUR_the_montreux_convention
								controls_province = 6864
								controls_province = 922
								340 = {
									is_demilitarized_zone = yes
								}
								NOT = { has_country_flag = TUR_strait_compromise_set }
							}
							NOT = { has_war_with = TUR }  	
						}
						AND = { #Bosphorus Compromise. As long as Turkey controls the Dardanelles and they're not at war with them, any country that owns a state bordering the Black Sea is treated as a "Friend"
							TUR = {
								controls_province = 6864
								controls_province = 922
								has_country_flag = TUR_strait_compromise_set
							}
							NOT = { has_war_with = TUR }  	
							TUR_owns_state_in_black_sea = yes 
						}
						AND = { #R56 addition, vanilla forgot to implement this global flag used in Turkey's ft
							TUR = {
								controls_state = 797
							}
							NOT = { has_war_with = TUR }  	
							has_country_flag = TUR_gets_strait_access
						}
						797 = { #This so countries allied to the controller of the Dardanelles can cross them. 
							controller = { 
								OR = {
									is_in_faction_with = ROOT 
									ROOT = { has_military_access_to = PREV }
									is_subject_of = ROOT
								}
							}
						}
						ROOT = { #So the controller can cross their own strait 
							AND = {
								controls_province = 6864
								controls_province = 922
							}
						}
					}
				}
				set_country_flag = friend_for_dardanelles
			}
			if = { 
				limit = {
					country_exists = ISR
					TAG = ISR
					EGY = {
						OR = {
							controls_province = 4073
							controls_province = 12049
							controls_province = 13281
							controls_province = 13282
						}
						has_country_flag = ISR_egypt_blockaded_suez
						NOT = {
							is_ally_with = ISR
						}
					}
				}
				ISR = {
					set_country_flag = ISR_egypt_blockaded_suez_wia	
				}
			}
			else = {
				clr_global_flag = ISR_egypt_blockaded_suez_wia
			}
			if = {
				limit = {
					country_exists = ISR
					995 = {
						is_controlled_by = ISR
					}
					911 = {
						is_controlled_by = EGY
					}
					ISR = {
						NOT = {
							has_war_with = EGY
						}
					}
				}
				set_global_flag = contested_suez_wia
			}
			else = {
				clr_global_flag = contested_suez_wia
			}
			if = {
				limit = {
					country_exists = ISR
					TAG = ISR
					EGY = {
						OR = {
							controls_province = 10099 
							controls_province = 12101
						}
						NOT = {
							has_country_flag = ISR_egypt_tiran_lifted
						}
						NOT = {
							is_ally_with = ISR
						}
					}
				}
				ISR = {
					set_country_flag = ISR_egypt_blockaded_tiran	
				}
				
			}
			else = {
				every_country = {
					limit = {
						has_country_flag = ISR_egypt_blockaded_tiran
					}
				}
				clr_country_flag = ISR_egypt_blockaded_tiran
			}
		}
	}
}