on_actions = { 
# ROOT is capitulated country, FROM is winner
	on_capitulation = {
		effect = {
			if = {
				limit = {
					GRE = { has_country_flag = GRE_megali_idea_approved }
					original_tag = TUR
					has_war_with = GRE
				}
				GRE = { country_event = { id = bftb_greece.208 days = 0 } }
			}
		}
	}
	on_war = {
		effect = {
			if = {
				limit = {
					original_tag = GRE
					GRE = { has_idea = GRE_booming_tourism }
				}
				GRE = { remove_ideas = GRE_booming_tourism }
			}
		}
		effect = {
			if = {
				limit = {
					original_tag = TUR
					TUR = { 
						AND = {
							has_completed_focus = TUR_invite_german_officers_to_izmir
							NOT = { has_completed_focus = TUR_integrate_german_officers_into_the_army }
						}
						has_war_with = GER
						has_unit_leader = 75
					}
				}
				TUR = { 
					remove_ideas = TUR_german_advisors 
					GER_hans_von_luck = { set_nationality = GER }
				} 
			}
			if = {
				limit = {
					original_tag = TUR
					TUR = { 
						AND = {
							has_completed_focus = TUR_invite_german_officers_to_izmir
							NOT = { has_completed_focus = TUR_integrate_german_officers_into_the_army }
						}
						has_war_with = GER
						has_unit_leader = 76
					}
				}
				TUR = {
					GER_wilhelm_ritter_von_thoma = { set_nationality = GER }
				} 
			}
			if = {
				limit = {
					original_tag = TUR
					TUR = { 
						has_completed_focus = TUR_the_italo_turkish_naval_academy
						has_war_with = ITA
						has_unit_leader = 77
					}
				}
				TUR = { 
					remove_ideas = TUR_the_antalya_naval_academy
					ITA_ferdinando_umberto_filippo_adalberto = { set_nationality = ITA }
				} 
			}
			if = {
				limit = {
					original_tag = TUR
					TUR = { 
						has_country_flag = TUR_the_chester_concession_flag
						has_war_with = USA
					}
				}
				TUR = {
					add_offsite_building = {  type = industrial_complex level = -3 }
				}
			}
		}
	}
	#ROOT is new controller #FROM is old controller #FROM.FROM is state ID
	on_state_control_changed = {
		effect = {
			if = {
				limit = {
					FROM.FROM = { state = 341 }
					ROOT = { has_country_flag = BOSPHORUS_STRAIT_BLOCKED_FOR_COUNTRY }
				}
				GRE = { clr_country_flag = BOSPHORUS_STRAIT_BLOCKED_FOR_COUNTRY }
				SOV = { clr_country_flag = BOSPHORUS_STRAIT_BLOCKED_FOR_COUNTRY }
			}
		}

		effect = { #Check for Turkish state modifiers for non-Turkish occupiers
			if = {
				limit = {
					FROM = { original_tag = TUR }
					ROOT = { NOT = { tag = TUR } }
					FROM.FROM = { 
						TUR_has_turkish_state_modifier = yes 
					}
				}
				FROM.FROM = { 
					TUR_remove_state_modifier_effect = yes
				}
			}
		}
		effect = { #Check for lost Turkish state modifiers
			if = {
				limit = {
					FROM.FROM = { 
						AND = { 
							is_owned_and_controlled_by = TUR
							TUR_has_former_turkish_state_modifier = yes
						}
					}
				}
				FROM.FROM = {
					TUR_restore_dynamic_modifiers_effect = yes
				}
			}		
		}
		effect = { #Check for Macedonian state modifiers
			if = {
				limit = {
					FROM.FROM = { BUL_is_macedonian_state = yes }
				}
				#Widespread Sentiment
				if = {
					limit = {
						FROM.FROM = { has_dynamic_modifier = { modifier = widespread_bulgarian_sentiment_01 } }
						ROOT = { tag = BUL }
					}
					FROM.FROM = {
						remove_dynamic_modifier = { modifier = widespread_bulgarian_sentiment_01 }
						add_dynamic_modifier = { modifier = widespread_bulgarian_sentiment_02 }
					}
				}
				else_if = {
					limit = {
						FROM.FROM = { has_dynamic_modifier = { modifier = widespread_bulgarian_sentiment_02 } }
						ROOT = { NOT = { tag = BUL } }
					}
					FROM.FROM = {
						remove_dynamic_modifier = { modifier = widespread_bulgarian_sentiment_02 }
						add_dynamic_modifier = { modifier = widespread_bulgarian_sentiment_01 }
					}
				}
				#IMRO Skirmishes
				if = {
					limit = {
						FROM.FROM = {
							has_dynamic_modifier = { modifier = skirmishes_against_imro }
						}
						ROOT = { tag = BUL }
					}
					FROM.FROM = {
						remove_dynamic_modifier = { modifier = skirmishes_against_imro }
					}
				}
			}
		}
	}

	#FROM is faction leader on join faction requests. THIS DOES NOT FIRE ON ADD_TO_FACTION EFFECT! USE ON_OFFER_JOIN_FACTION!
	on_join_faction = {
		effect = {
			if = {
				limit = {
					original_tag = GRE
					OR = { 
						GRE = { has_idea = GRE_metaxism }
						GRE = { has_idea = GRE_metaxism_2 }
						GRE = { has_idea = GRE_metaxism_3 }
						GRE = { has_idea = GRE_metaxism_4 }
						GRE = { has_idea = GRE_metaxism_5 }
					}
				}
				GRE = { 
					remove_ideas = GRE_metaxism
					remove_ideas = GRE_metaxism_2 
					remove_ideas = GRE_metaxism_3 
					remove_ideas = GRE_metaxism_4 
					remove_ideas = GRE_metaxism_5 
				}
			}
		}
		effect = { #If in faction with Bulgaria, remove bad opinion modifiers
			if = { #A country joins Bulgaria's faction
				limit = {
					NOT = { original_tag = BUL }
					FROM = {
						OR = {
							is_in_faction_with = BUL
							original_tag = BUL
						}
					}
				}
				BUL_remove_balkan_opinion_modifiers = yes
			}
			else_if = { #Bulgaria joins a faction
				limit = {
					original_tag = BUL
					FROM = {
						any_allied_country = {
							BUL_is_balkan_nation_no_bulgaria = yes
						}
					}
				}
				every_other_country = {
					limit = {
						is_in_faction_with = FROM
						BUL_is_balkan_nation_no_bulgaria = yes
					}
					BUL_remove_balkan_opinion_modifiers = yes
				}
			}
		}
	}

	#FROM is country getting invited.
	on_offer_join_faction = {
		effect = { #If in faction with Bulgaria, remove bad opinion modifiers
			if = { #A country joins Bulgaria's faction
				limit = {
					is_in_faction_with = BUL
					FROM = {
						NOT = { original_tag = BUL }
					}
				}
				FROM = { BUL_remove_balkan_opinion_modifiers = yes }
			}
			else_if = { #Bulgaria joins a faction
				limit = {
					FROM = {
						original_tag = BUL
					}
					OR = {
						BUL_is_balkan_nation_no_bulgaria = yes
						any_allied_country = {
							BUL_is_balkan_nation_no_bulgaria = yes
						}
					}
				}
				every_country = {
					limit = {
						OR = {
							tag = PREV
							is_in_faction_with = PREV
						}
						BUL_is_balkan_nation_no_bulgaria = yes
					}
					BUL_remove_balkan_opinion_modifiers = yes
				}
			}
		}
	}

	on_startup = {
		effect = {
			#Iraqi oil concessions
			if = {
				limit = {
					has_dlc = "Battle for the Bosporus"
				}
				IRQ = {
					give_resource_rights = { receiver = ENG state = 291 }
					give_resource_rights = { receiver = ENG state = 676 }
					give_resource_rights = { receiver = ENG state = 1010 }
				}
			}
		}
		effect = {
			#Greek faction set-up
			if = {
				limit = {
					has_dlc = "Battle for the Bosporus"
					has_start_date < 1936.1.2
				}
				GRE = { 
					set_country_flag = GRE_factions_unlocked
					set_variable = { var  = GRE_monarchist_loyalty value = 2 }
					set_variable = { var  = GRE_republican_loyalty value = -1 }
					set_variable = { var  = GRE_communist_loyalty value = -1 }
					set_variable = { var  = GRE_fascist_loyalty value = -2 }
					GRE_political_instability_update_effect = yes
				}
			}
		}
	}

	#ROOT is winner #FROM gets annexed - This will also fire on_annex
	on_civil_war_end = {
		effect = {
			if = {
				limit = {
					original_tag = GRE
					date < 1937.01.01
				}
				set_country_flag = achievement_greek_civility
			}
			if = {
				limit = {
					any_country = { 
						AND = { 
							has_country_flag = TUR_iraqi_government_flag 
							exists = yes
						}
					}
				}
				TUR = {  
					create_wargoal = {
						type = puppet_wargoal_focus
						target = IRQ
					}
				}
			}
			else_if = {
				limit = {
					any_country = { 
						AND = { 
							has_country_flag = TUR_iraqi_fascists_flag 
							exists = yes
						}
					}
				}
				ENG = { 
					remove_resource_rights = 676
					remove_resource_rights = 291
				}
				TUR = { country_event = { id = bftb_turkey.69 hours = 6 } } 
				GER = { country_event = { id = bftb_turkey.71 hours = 8 } } 
				ITA = { country_event = { id = bftb_turkey.73 hours = 8 } } 
				if = {
					limit = {
						IRQ = { NOT = { has_idea = nationalism } }
					}
					add_ideas = nationalism
				}
			}
		}
		effect = {
			if = { 
				limit = {
					original_tag = BUL
					has_dlc = "Battle for the Bosporus"
				}
				#Set Sofia as capital
				if = {
					limit = {
						controls_state = 48
						48 = { is_capital = no }
					}
					set_capital = { state = 48 }
				}
				if = { #Unlock faction interaction
					limit = {					
						NOT = { has_country_flag = BUL_factions_unlocked_flag }
						NOT = { has_focus_tree = generic_focus }
					}
					set_country_flag = BUL_factions_unlocked_flag
				}
				if = { #ZVENO Bulgaria won the CW
					limit = {
						has_cosmetic_tag = BUL_zveno_bulgaria
						has_focus_tree = generic_focus
					}
					load_focus_tree = { tree = bulgarian_focus keep_completed = no }
					unlock_national_focus = BUL_power_to_the_tsar
					unlock_national_focus = BUL_cooperate_with_the_zveno
					unlock_national_focus = BUL_condemn_macedonian_organizations
					unlock_national_focus = BUL_appoint_right_wing_ministers
					unlock_national_focus = BUL_promote_bulgarian_nationalism
					unlock_national_focus = BUL_bulgarian_irredentism
					unlock_national_focus = BUL_depose_the_tsar
					unlock_national_focus = BUL_military_dictatorship

					#Initialize vars
					BUL_set_buz_faction_values = yes

					if = {
						limit = {
							has_government = fascism
						}
						unlock_national_focus = BUL_allow_far_right_organizations
					}
					set_country_flag = BUL_zveno_integrated_flag
					clr_country_flag = BUL_zveno_coup_flag
				}
				else_if = { #Original BUL won the CW against ZVENO
					limit = {
						FROM = {
							has_cosmetic_tag = BUL_zveno_bulgaria
						}
					}
					if = {
						limit = {
							NOT = { has_completed_focus = BUL_dissolve_the_military_union }
						}
						unlock_national_focus = BUL_dissolve_the_military_union
					}
					set_country_flag = BUL_zveno_destroyed_flag
					set_country_flag = BUL_factions_unlocked_flag
					clr_country_flag = BUL_zveno_coup_flag
				}
				else_if = { #FATHERLAND FRONT won the CW
					limit = {
						original_tag = BUL
						has_country_flag = BUL_fatherland_front_flag
						has_focus_tree = generic_focus
					}
					#FOCUS TREE
					load_focus_tree = { tree = bulgarian_focus keep_completed = no }
					unlock_national_focus = BUL_oppose_the_royal_dictatorship
					unlock_national_focus = BUL_appoint_communist_ministers
					unlock_national_focus = BUL_unify_the_bourgeois_movement
					unlock_national_focus = BUL_united_front_against_fascism
					unlock_national_focus = BUL_the_fatherland_front
					unlock_national_focus = BUL_overthrow_the_tsar
					unlock_national_focus = BUL_the_peoples_republic_of_bulgaria
					unlock_national_focus = BUL_condemn_macedonian_organizations
					unlock_national_focus = BUL_acquire_modern_tools
					unlock_national_focus = BUL_negotiate_bulgarian_rearmament

					if = { #Lock faction interaction
						limit = {					
							has_country_flag = BUL_factions_unlocked_flag
						}
						clr_country_flag = BUL_factions_unlocked_flag
					}
					#SET Faction flags
					if = {
						limit = {
							FROM = {
								has_country_flag = BUL_zveno_joined_ff_flag
							}
						}
						set_country_flag = BUL_zveno_integrated_flag
						unlock_national_focus = BUL_cooperate_with_the_zveno
					}
					else = {
						set_country_flag = BUL_zveno_destroyed_flag
						unlock_national_focus = BUL_dissolve_the_military_union
					}
					if = {
						limit = {
							FROM = {
								has_country_flag = BUL_bs_joined_ff_flag
							}
						}
						set_country_flag = BUL_bs_integrated_flag
					}
					else = {
						set_country_flag = BUL_bs_destroyed_flag
					}
					if = {
						limit = {
							FROM = {
								has_country_flag = BUL_bzns_joined_ff_flag
							}
						}
						set_country_flag = BUL_bzns_integrated_flag
					}
					else = {
						set_country_flag = BUL_bzns_destroyed_flag
					}
					set_country_flag = BUL_nsm_destroyed_flag				

					hidden_effect = { #NEWS EVENT SO THE WORLD KNOW WHO RULES IN BULGARIA
						news_event = { id = bftb_news.8 hours = 4 random_hours = 4 }
					}
				}
			}
		}
		effect = { #SCW
			if = {
				limit = {
					FROM = {
						original_tag = SPR
					}
					NOT = {
						any_other_country = {
							NOT = {
								tag = ROOT
								tag = FROM
							}
							original_tag = SPR
							exists = yes
						}
					}
				}
				if = {
					limit = {
						BUL = { has_country_flag = BUL_sent_volunteers_to_SPD_flag }
					}
					BUL = { 
						set_country_flag = BUL_back_from_the_scw_flag
						country_event = { id = bftb_bulgaria_scw_volunteers.1 hours = 12 random_hours = 8 }
						clr_country_flag = BUL_sent_volunteers_to_SPD_flag
					}
				}
				else_if = {
					limit = {
						BUL = { has_country_flag = BUL_sent_volunteers_to_SPA_flag }
					}
					BUL = {						
						country_event = { id = bftb_bulgaria_scw_volunteers.2 hours = 12 random_hours = 8 }
						clr_country_flag = BUL_sent_volunteers_to_SPA_flag
					}
				}
			}
		}
	}

	# called when a country send volunteers to another
	# ROOT is sender, FROM is receiver
	on_send_volunteers = {
		effect = {
			if = { #Bulgaria has sent volunteers to Spanish Republicans/Nationalists (LaR)
				limit = {
					tag = BUL
					FROM = { original_tag = SPR }
					has_dlc = "La Resistance"
					SPR_scw_in_progress = yes
				}
				if = {
					limit = {
						FROM = { tag = SPD }
					}
					set_country_flag = BUL_sent_volunteers_to_SPD_flag
				}
				else = {
					set_country_flag = BUL_sent_volunteers_to_SPA_flag
				}
			}
			else_if = {
				limit = {
					tag = BUL
					FROM = { original_tag = SPR }
					NOT = { has_dlc = "La Resistance" }
					FROM = { has_civil_war = yes }
				}
				if = {
					limit = {
						FROM = {
							OR = {
								has_government = democratic
								has_government = communism
							}
						}
					}
					set_country_flag = BUL_sent_volunteers_to_SPD_flag
				}
				else = {
					set_country_flag = BUL_sent_volunteers_to_SPA_flag
				}
			}	
		}
	}

	on_ruling_party_change = {
		# Change 3D Models based on ideology
		effect = {
			if = {
				limit = {
					original_tag = BUL
				}
				if = { #BUL - TBE
					limit = {
						has_country_flag = BUL_tbe_flag
					}
					if = {
						limit = {
							has_government = communism
						}
						set_cosmetic_tag = TBE_third_bulgarian_empire_communism
					}
					else_if = {
						limit = {
							has_government = democratic
						}
						set_cosmetic_tag = TBE_third_bulgarian_empire_democratic
					}
					else_if = {
						limit = {
							has_government = fascism
						}
						set_cosmetic_tag = TBE_third_bulgarian_empire_fascism
					}
					else = {
						limit = {
							has_government = neutrality
						}
						set_cosmetic_tag = TBE_third_bulgarian_empire_neutrality
					}
				}
				else_if = {  #BUL - UBF
					limit = {
						has_country_flag = BUL_ubf_flag
					}
					if = {
						limit = {
							has_government = communism
						}
						set_cosmetic_tag = UBF_united_balkan_federation_communism
					}
					else_if = {
						limit = {
							has_government = democratic
						}
						set_cosmetic_tag = UBF_united_balkan_federation_democratic
					}
					else_if = {
						limit = {
							has_government = fascism
						}
						set_cosmetic_tag = UBF_united_balkan_federation_fascism
					}
					else = {
						limit = {
							has_government = neutrality
						}
						set_cosmetic_tag = UBF_united_balkan_federation_neutrality
					}
				}
				else_if = { #BUL - The fabulous original one
					limit = {
						NOT = { has_cosmetic_tag = BUL_zveno_bulgaria } # NOT Zveno Bulgaria
					}
					if = {
						limit = {
							has_government = communism
							NOT = { has_cosmetic_tag = BUL_ff_bulgaria } # NOT Fatherland Front Bulgaria
						}
						set_cosmetic_tag = BUL_communism
					}
					else_if = { #Default democratic Bulgaria's name is "Republic of Bulgaria", so it is to be applied only if monarchy is actually abolished
						limit = {
							has_government = communism
							has_cosmetic_tag = BUL_ff_bulgaria # Fatherland Front Bulgaria
						}
						#DO NOTHING
					}
					else_if = {
						limit = {
							has_government = democratic
							has_completed_focus = BUL_abolish_the_monarchy
						}
						if = {
							limit = {
								has_cosmetic_tag = BUL_ff_bulgaria #Remove FF cosmetic
							}
							drop_cosmetic_tag = yes
						}
						set_cosmetic_tag = BUL_democratic
						set_country_leader_ideology = socialism
					}
					else_if = { #Cosmetic tag with a non-republican name, so it is to be applied as long as monarchy has not been abolished
						limit = {
							has_government = democratic
							NOT = { has_completed_focus = BUL_abolish_the_monarchy }
						}
						set_cosmetic_tag = BUL_constitutional_monarchy
					}
					else_if = {
						limit = {
							has_government = fascism
						}
						if = {
							limit = {
								has_cosmetic_tag = BUL_ff_bulgaria #Remove FF cosmetic
							}
							drop_cosmetic_tag = yes
						}
						set_cosmetic_tag = BUL_fascism
					}
					else = {
						limit = {
							has_government = neutrality
						}
						if = {
							limit = {
								has_cosmetic_tag = BUL_ff_bulgaria #Remove FF cosmetic
							}
							drop_cosmetic_tag = yes
						}
						set_cosmetic_tag = BUL_neutrality
					}
				}
			}
			else_if = {
				limit = {
					original_tag = GRE
				}
				if = { #GRE - BYZ_UNIFIED
					limit = {
						has_country_flag = GRE_byz_unified_flag
					}
					if = {
						limit = {
							has_government = communism
						}
						set_cosmetic_tag = BYZ_UNIFIED_communism
					}
					else_if = {
						limit = {
							has_government = democratic
						}
						set_cosmetic_tag = BYZ_UNIFIED_democratic
					}
					else_if = {
						limit = {
							has_government = fascism
						}
						set_cosmetic_tag = BYZ_UNIFIED_fascism
					}
					else = {
						limit = {
							has_government = neutrality
						}
						set_cosmetic_tag = BYZ_UNIFIED_neutrality
					}
				}
				else_if = { #GRE BYZANTINE REPUBLIC
					limit = {
						has_cosmetic_tag = GRE_byz_republic
					}
					#DO NOTHING, this cosmetic does not have dynamic models
				}
				else_if = { #GRE - GRE_GREATER_GREECE
					limit = {
						has_country_flag = GRE_GREATER_GREECE_flag
					}
					if = {
						limit = {
							has_government = communism
						}
						set_cosmetic_tag = GRE_GREATER_GREECE_communism
					}
					else_if = {
						limit = {
							has_government = democratic
						}
						set_cosmetic_tag = GRE_GREATER_GREECE_democratic
					}
					else_if = {
						limit = {
							has_government = fascism
						}
						set_cosmetic_tag = GRE_GREATER_GREECE_fascism
					}
					else = {
						limit = {
							has_government = neutrality
						}
						set_cosmetic_tag = GRE_GREATER_GREECE_neutrality
					}
				}
				else_if = { #GRE - GRE_dem_monarchy
					limit = {
						has_country_flag = GRE_dem_monarchy_flag
					}
					if = {
						limit = {
							has_government = communism
						}
						set_cosmetic_tag = GRE_dem_monarchy_communism
					}
					else_if = {
						limit = {
							has_government = democratic
						}
						set_cosmetic_tag = GRE_dem_monarchy_democratic
					}
					else_if = {
						limit = {
							has_government = fascism
						}
						set_cosmetic_tag = GRE_dem_monarchy_fascism
					}
					else = {
						limit = {
							has_government = neutrality
						}
						set_cosmetic_tag = GRE_dem_monarchy_neutrality
					}
				}
				else_if = { #GRE - Stalinist
					limit = {
						has_cosmetic_tag = GRE_stalinist
					}
					#DO NOTHING, this cosmetic does not have dynamic models
				}
				else_if = { #GRE - GRE_com_independent
					limit = {
						has_country_flag = GRE_com_independent_flag
					}
					if = {
						limit = {
							has_government = communism
						}
						set_cosmetic_tag = GRE_com_independent_communism
					}
					else_if = {
						limit = {
							has_government = democratic
						}
						set_cosmetic_tag = GRE_com_independent_democratic
					}
					else_if = {
						limit = {
							has_government = fascism
						}
						set_cosmetic_tag = GRE_com_independent_fascism
					}
					else = {
						limit = {
							has_government = neutrality
						}
						set_cosmetic_tag = GRE_com_independent_neutrality
					}
				}
				else_if = { #GRE - MAE
					limit = {
						has_country_flag = GRE_mae_flag
					}
					if = {
						limit = {
							has_government = communism
						}
						set_cosmetic_tag = MAE_communism
					}
					else_if = {
						limit = {
							has_government = democratic
						}
						set_cosmetic_tag = MAE_democratic
					}
					else_if = {
						limit = {
							has_government = fascism
						}
						set_cosmetic_tag = MAE_fascism
					}
					else = {
						limit = {
							has_government = neutrality
						}
						set_cosmetic_tag = MAE_neutrality
					}
				}
				else = { #GRE - The one and only
					if = {
						limit = {
							has_government = communism
						}
						set_cosmetic_tag = GRE_communism
					}
					else_if = {
						limit = {
							has_government = democratic
						}
						set_cosmetic_tag = GRE_democratic
					}
					else_if = {
						limit = {
							has_government = fascism
						}
						set_cosmetic_tag = GRE_fascism
					}
					else = {
						limit = {
							has_government = neutrality
						}
						set_cosmetic_tag = GRE_neutrality
					}
				}
			}
			else_if = {
				limit = {
					original_tag = TUR
				}
				if = { #TUR - OTT_UNIFIED
					limit = {
						has_country_flag = TUR_ott_unified_flag
					}
					if = {
						limit = {
							has_government = communism
						}
						set_cosmetic_tag = OTT_UNIFIED_communism
					}
					else_if = {
						limit = {
							has_government = democratic
						}
						set_cosmetic_tag = OTT_UNIFIED_democratic
					}
					else_if = {
						limit = {
							has_government = fascism
						}
						set_cosmetic_tag = OTT_UNIFIED_fascism
					}
					else_if = {
						limit = {
							has_government = neutrality
						}
						set_cosmetic_tag = OTT_UNIFIED_neutrality
					}
				}
				else_if = { #TUR - OTT_SULTANATE
					limit = {
						has_country_flag = TUR_ott_sultanate_flag
					}
					if = {
						limit = {
							has_government = communism
						}
						set_cosmetic_tag = OTT_SULTANATE_communism
					}
					else_if = {
						limit = {
							has_government = democratic
						}
						set_cosmetic_tag = OTT_SULTANATE_democratic
					}
					else_if = {
						limit = {
							has_government = fascism
						}
						set_cosmetic_tag = OTT_SULTANATE_fascism
					}
					else_if = {
						limit = {
							has_government = neutrality
						}
						set_cosmetic_tag = OTT_SULTANATE_neutrality
					}
				}
				else_if = { #TUR - TUR_PROVISIONARY
					limit = {
						has_country_flag = TUR_PROVISIONARY_flag
					}
					if = {
						limit = {
							has_government = communism
						}
						set_cosmetic_tag = TUR_PROVISIONARY_communism
					}
					else_if = {
						limit = {
							has_government = democratic
						}
						set_cosmetic_tag = TUR_PROVISIONARY_democratic
					}
					else_if = {
						limit = {
							has_government = fascism
						}
						set_cosmetic_tag = TUR_PROVISIONARY_fascism
					}
					else_if = {
						limit = {
							has_government = neutrality
						}
						set_cosmetic_tag = TUR_PROVISIONARY_neutrality
					}
				}
				else_if = { #TUR - TUR_GREATER_TURKEY
					limit = {
						has_country_flag = TUR_greater_turkey_flag
					}
					if = {
						limit = {
							has_government = communism
						}
						set_cosmetic_tag = TUR_GREATER_TURKEY_communism
					}
					else_if = {
						limit = {
							has_government = democratic
						}
						set_cosmetic_tag = TUR_GREATER_TURKEY_democratic
					}
					else_if = {
						limit = {
							has_government = fascism
						}
						set_cosmetic_tag = TUR_GREATER_TURKEY_fascism
					}
					else_if = {
						limit = {
							has_government = neutrality
						}
						set_cosmetic_tag = TUR_GREATER_TURKEY_neutrality
					}
				}
				else_if = { #TRN
					limit = {
						has_country_flag = TUR_trn_flag
					}
					if = {
						limit = {
							has_government = communism
						}
						set_cosmetic_tag = TRN_communism
					}
					else_if = {
						limit = {
							has_government = democratic
						}
						set_cosmetic_tag = TRN_democratic
					}
					else_if = {
						limit = {
							has_government = fascism
						}
						set_cosmetic_tag = TRN_fascism
					}
					else_if = {
						limit = {
							has_government = neutrality
						}
						set_cosmetic_tag = TRN_neutrality
					}
				}
				else = { #TUR - The real TUR
					if = {
						limit = {
							has_government = communism
						}
						set_cosmetic_tag = TUR_communism
					}
					else_if = {
						limit = {
							has_government = democratic
						}
						set_cosmetic_tag = TUR_democratic
					}
					else_if = {
						limit = {
							has_government = fascism
						}
						set_cosmetic_tag = TUR_fascism
					}
					else_if = {
						limit = {
							has_government = neutrality
						}
						set_cosmetic_tag = TUR_neutrality
					}
				}
			}
		}
		effect = {
			if = {
				limit = {
					original_tag = BUL
				}
				if = {
					limit = {
						has_government = communism
						has_country_flag = BUL_player_formed_fatherland_front_flag
					}
					add_ideas = BUL_fatherland_front_positive
					clr_country_flag = BUL_player_formed_fatherland_front_flag
				}
				else_if = {
					limit = {
						has_government = fascism
						has_idea = BUL_bogdan_filov
					}
					remove_ideas = BUL_bogdan_filov
					add_ideas = BUL_bogdan_filov_fascism
				}
				else_if = {
					limit = {
						has_government = neutrality
						has_idea = BUL_bogdan_filov_fascism
					}
					remove_ideas = BUL_bogdan_filov_fascism
					add_ideas = BUL_bogdan_filov
				}
			}
		}
		effect = {
			if = {
				limit = {
					original_tag = BUL
					has_country_leader = {
						character = BUL_ferdinand_i 
						ruling_only = yes
					}
					num_subjects > 0
				}
				every_other_country = {
					limit = {
						is_subject_of = BUL
						NOT = { has_idea = BUL_ferdinands_puppet }
					}
					add_ideas = BUL_ferdinands_puppet
				}
			}
			else_if = {
				limit = {
					original_tag = BUL
					has_country_flag = BUL_the_return_of_ferdinand_flag
					NOT = {
						has_country_leader = {
							character = BUL_ferdinand_i 
							ruling_only = yes
						}
					}
					num_subjects > 0
				}
				every_other_country = {
					limit = {
						is_subject_of = BUL
						has_idea = BUL_ferdinands_puppet
					}
					remove_ideas = BUL_ferdinands_puppet
				}
			}
		}
	}

	on_weekly_BUL = {
		effect = {
			# FATHERLAND FRONT
			if = {
				limit = {
					has_dlc = "Battle for the Bosporus"
					NOT = { has_country_flag = BUL_fatherland_front_formed_flag }
					NOT = { has_completed_focus = BUL_the_fatherland_front }
					date > 1941.6.1 #Previously date > 1940.1.1 but it felt too punishing
				}
				BUL_communists_try_to_form_ff_effect = yes
			}
			else_if = {
				limit = {
					NOT = { has_country_flag = BUL_ff_civil_war_flag }
					NOT = { has_country_flag = BUL_ff_destroyed_flag }
					has_country_flag = { flag = BUL_fatherland_front_formed_flag days > 60 } #Give the player some time after FF formation
					OR = {
						NOT = { has_country_flag = BUL_ff_approaching_faction_flag }
						has_country_flag = { flag = BUL_ff_approaching_faction_flag days > 30 }
					}
				}
				log = "checking if FF approaches someone"
				# CHECK IF FF APPROACHES ANY BULARIAN INTERNAL FACTION
				BUL_ff_approaches_a_faction_effect = yes #Random chance

				if = { # Check if FF approaches BROAD SOCIALISTS
					limit = { 
						NOT = { has_country_flag = BUL_bs_joined_ff_flag }
						NOT = { has_country_flag = BUL_bs_destroyed_flag }
						NOT = { has_country_flag = BUL_bs_integrated_flag }
					}
					set_temp_variable = { BUL_bs_loyalty_factor = 100 }
					subtract_from_temp_variable = { BUL_bs_loyalty_factor = BUL_bs_loyalty }
					if = {
						limit = {
							check_variable = { BUL_bs_loyalty_factor = BUL_random_ff_approaching_faction_chance compare = greater_than_or_equals }
						}
						if = {
							limit = { has_country_flag = BUL_ff_approaching_faction_flag }
							clr_country_flag = BUL_ff_approaching_faction_flag
						}
						set_country_flag = BUL_bs_joined_ff_flag
						set_country_flag = BUL_ff_approaching_faction_flag
						activate_mission = BUL_ff_approaching_bs_mission

						log = "FF approaches BS: [?BUL.BUL_bs_loyalty_factor] is greater than [?BUL.BUL_random_ff_approaching_faction_chance]"
					}
					else = {
						log = "FF DOES NOT approach BS: [?BUL.BUL_bs_loyalty_factor] is lower than [?BUL.BUL_random_ff_approaching_faction_chance]"
					}
				}
				else_if = { # Check if FF approaches AGRARIAN NATIONAL UNION
					limit = {
						NOT = { has_country_flag = BUL_bzns_joined_ff_flag }
						NOT = { has_country_flag = BUL_bzns_destroyed_flag }
						NOT = { has_country_flag = BUL_bzns_integrated_flag }
					}
					set_temp_variable = { BUL_bzns_loyalty_factor = 100 }
					subtract_from_temp_variable = { BUL_bzns_loyalty_factor = BUL_bs_loyalty }
					if = {
						limit = {
							check_variable = { BUL_bzns_loyalty_factor = BUL_random_ff_approaching_faction_chance compare = greater_than_or_equals }
						}
						if = {
							limit = { has_country_flag = BUL_ff_approaching_faction_flag }
							clr_country_flag = BUL_ff_approaching_faction_flag
						}
						set_country_flag = BUL_bzns_joined_ff_flag
						set_country_flag = BUL_ff_approaching_faction_flag
						activate_mission = BUL_ff_approaching_bzns_mission

						log = "FF approaches BZN: [?BUL.BUL_bzns_loyalty_factor] is greater than [?BUL.BUL_random_ff_approaching_faction_chance]"
					}
					else = {
						log = "FF DOES NOT approach BZNS: [?BUL.BUL_bzns_loyalty_factor] is lower than [?BUL.BUL_random_ff_approaching_faction_chance]"
					}
				}
				else_if = { # Check if FF approaches ZVENO
					limit = { 
						NOT = { has_country_flag = BUL_zveno_joined_ff_flag }
						NOT = { has_country_flag = BUL_zveno_coup_flag }
						NOT = { has_country_flag = BUL_zveno_destroyed_flag }
						NOT = { has_country_flag = BUL_zveno_integrated_flag }
					}
					set_temp_variable = { BUL_zveno_loyalty_factor = 100 }
					subtract_from_temp_variable = { BUL_zveno_loyalty_factor = BUL_zveno_loyalty }
					if = {
						limit = {
							check_variable = { BUL_zveno_loyalty_factor = BUL_random_ff_approaching_faction_chance compare = greater_than_or_equals }
						}
						if = {
							limit = { has_country_flag = BUL_ff_approaching_faction_flag }
							clr_country_flag = BUL_ff_approaching_faction_flag
						}
						set_country_flag = BUL_zveno_joined_ff_flag
						set_country_flag = BUL_ff_approaching_faction_flag
						activate_mission = BUL_ff_approaching_zveno_mission

						log = "FF approaches ZVENO: [?BUL.BUL_zveno_loyalty_factor] is greater than [?BUL.BUL_random_ff_approaching_faction_chance]"
					}
					else = {
						log = "FF DOES NOT approach ZVENO: [?BUL.BUL_zveno_loyalty_factor] is lower than [?BUL.BUL_random_ff_approaching_faction_chance]"
					}
				}
				if = {
					limit = {
						has_country_flag = BUL_ff_coup_planned_flag
						date > 1943.1.1
					}
					BUL_ff_tries_to_stage_a_coup_effect = yes #Check if the FF starts the CW
				}					
			}

			# BULGARIAN CLAIMS IN THE BALKANS
			if = {
				limit = {
					has_global_flag = BUL_germany_recognizes_bulgarian_claims_flag
					is_in_faction_with = GER
					any_state = {
						has_state_flag = BUL_bulgarian_claim_warranted_flag
						OR = {
							is_controlled_by = GER
							controller = {
								is_in_faction_with = GER
								NOT = { tag = BUL }
								NOT = { owns_state = PREV } #Not owner (it should be actually occupating the state -> Also prevents the issue in YUG with IMRO removing the core)
								#NOT = { PREV.PREV = { is_core_of = PREV } }
							}
						}
					}
				}
				country_event = bftb_bulgarian_claims.4
			}
		}
		#Check for any subject not having the appropriate NS while Ferdinand I is ruling (ie. released nations)
		effect = {
			if = {
				limit = {
					has_country_leader = {
						character = BUL_ferdinand_i 
						ruling_only = yes
					}
					any_country = {
						is_subject_of = ROOT
						NOT = { has_idea = BUL_ferdinands_puppet }
					}
				}
				every_country = {
					limit = {
						is_subject_of = ROOT
						NOT = { has_idea = BUL_ferdinands_puppet }
					}
					add_ideas = BUL_ferdinands_puppet
				}		
			}
		}

		#Retire Generals that do not agree with pro-German policies
		effect = {
			if = {
				limit = {
					is_in_faction_with = GER
					GER = { has_government = fascism }
				}
				random_unit_leader = {
					limit = {
						has_id = 1203 #Hadzipetkov
					}
					retire = yes
				}
				random_unit_leader = {
					limit = {
						has_id = 1204 #Boydev
					}
					retire = yes
				}
			}
		}
	}
	
	#ROOT = attacking side
	#FROM = defending side
	#fired when two countries end up at war with each other (on_war is fired when a country goes to war against anyone and is not fired again when it enters war against another country unless it went to peace first)
	on_war_relation_added = {
		effect = { #Bulgaria vs SOV -> Cooldown before high chance of FF forming up
			if = {
				limit = {
					OR = {
						AND = {
							ROOT = { original_tag = BUL }
							FROM = { original_tag = SOV }
						}
						AND = {
							ROOT = { original_tag = SOV }
							FROM = { original_tag = BUL }
						}
					}
					
					BUL = { NOT = { has_country_flag = BUL_at_war_with_the_soviets_flag } }
				}
				BUL = { set_country_flag = BUL_at_war_with_the_soviets_flag }
			}
		}
		effect = {
			if = {
				limit = {
					OR = {
						AND = {
							original_tag = ITA
							FROM = {
								original_tag = GRE
							}
						}
						AND = {
							original_tag = GRE
							FROM = {
								original_tag = ITA
							}
						}
					}
					OR = {
						has_country_flag = GRE_italy_attending_convention
						FROM = { has_country_flag = GRE_italy_attending_convention }
					}
				}
				GRE = {
					clr_country_flag = GRE_italy_attending_convention
				}
			}
		}
		effect = {
			if = {
				limit = { 
					FROM = {
						original_tag = BUL 
					}
					ROOT = {
						original_tag = BUL
					}
					YUG = { has_completed_focus = YUG_recognize_the_soviet_union }
				}
				random_country = {
					limit = {
						original_tag = BUL
						has_government = communism
					}
					set_cosmetic_tag = YUG_puppet_1
				}
			}
			if = {
				limit = { 
					FROM = {
						original_tag = ALB 
					}
					ROOT = {
						original_tag = ALB
					}
					YUG = { has_completed_focus = YUG_recognize_the_soviet_union }
				}
				random_country = {
					limit = {
						original_tag = ALB
						has_government = communism
					}
					set_cosmetic_tag = YUG_puppet_2
				}
			}
			if = {
				limit = { 
					FROM = {
						original_tag = GRE 
					}
					ROOT = {
						original_tag = GRE
					}
					YUG = { has_completed_focus = YUG_recognize_the_soviet_union }
				}
				random_country = {
					limit = {
						original_tag = GRE
						has_government = communism
					}
					set_cosmetic_tag = YUG_puppet_3
				}
			}
			if = {
				limit = { 
					FROM = {
						original_tag = ROM 
					}
					ROOT = {
						original_tag = ROM
					}
					YUG = { has_completed_focus = YUG_recognize_the_soviet_union }
				}
				random_country = {
					limit = {
						original_tag = ROM
						has_government = communism
					}
					set_cosmetic_tag = YUG_puppet_4
				}
			}
			if = {
				limit = { 
					FROM = {
						original_tag = HUN 
					}
					ROOT = {
						original_tag = HUN
					}
					YUG = { has_completed_focus = YUG_recognize_the_soviet_union }
				}
				random_country = {
					limit = {
						original_tag = HUN
						has_government = communism
					}
					set_cosmetic_tag = YUG_puppet_5
				}
			}
			if = {
				limit = { 
					FROM = {
						original_tag = TUR 
					}
					ROOT = {
						original_tag = TUR
					}
					YUG = { has_completed_focus = YUG_recognize_the_soviet_union }
				}
				random_country = {
					limit = {
						original_tag = TUR
						has_government = communism
					}
					set_cosmetic_tag = YUG_puppet_6
				}
			}
		}
	}

	#used when puppeting in a peace conference
	#ROOT = nation being puppeted, FROM = overlord
	on_puppet = {
		effect = { #Add Ferdinand's puppet NS
			if = {
				limit = {
					FROM = {
						original_tag = BUL
						has_country_leader = {
							character = BUL_ferdinand_i 
							ruling_only = yes
						}
					}
					NOT = { has_idea = BUL_ferdinands_puppet }
				}
				add_ideas = BUL_ferdinands_puppet
			}
		}
		effect = { #Remove bad opinion modifiers when puppetting
			if = { #If puppeted by Bulgaria, remove bad opinion modifiers
				limit = {
					BUL_is_balkan_nation_no_bulgaria = yes
					FROM = { original_tag = BUL }
				}
				BUL_remove_balkan_opinion_modifiers = yes
			}
			else_if = { #Bulgaria puppeted by a Balkan nation
				limit = {
					original_tag = BUL
					FROM = { BUL_is_balkan_nation_no_bulgaria = yes }
				}
				FROM = { BUL_remove_balkan_opinion_modifiers = yes }
			}
		}
	}

	on_leave_faction = {
		effect = {
			if = {
				limit = { 
					FROM = {
						original_tag = BUL
						has_completed_focus = BUL_the_fate_of_the_balkans
					}
				}
				FROM = {
					create_wargoal = {
						type = puppet_wargoal_focus
						target = ROOT
					}
				}
			}
		}
	}

	on_monthly_BUL = {
		effect = { #ZVENO DISSIDENT EVENT
			if = {
				limit = {
					date > 1937.6.1	#Give the player some time
					NOT = {	has_country_flag = BUL_zveno_destroyed_flag } #Zveno is not destroyed
					NOT = {	has_country_flag = BUL_zveno_legalized_flag } #Zveno is not legalized
				}
				BUL = { country_event = bftb_bulgaria_factions.01 }
			}
		}
		effect = { #BROAD SOCIALISTS DISSIDENT EVENT
			if = {
				limit = {
					date > 1936.6.1	#Give the player some time
					NOT = {	has_country_flag = BUL_bs_destroyed_flag } #BS is not destroyed
					NOT = {	has_country_flag = BUL_bs_legalized_flag } #BS is not legalized
				}
				BUL = { country_event = bftb_bulgaria_factions.02 }
			}
		}
		effect = { #AGRARIAN NATIONAL UNION DISSIDENT EVENT
			if = {
				limit = {
					date > 1938.1.1	#Give the player some time
					NOT = {	has_country_flag = BUL_bzns_destroyed_flag } #BZNS is not destroyed
					NOT = {	has_country_flag = BUL_bzns_legalized_flag } #BZNS is not legalized
				}
				BUL = { country_event = bftb_bulgaria_factions.03 }
			}
		}
		effect = { #NATIONAL SOCIAL MOVEMENT DISSIDENT EVENT
			if = {
				limit = {
					date > 1937.6.1	#Give the player some time
					NOT = {	has_country_flag = BUL_nsm_destroyed_flag } #NSM is not destroyed
					NOT = {	has_country_flag = BUL_nsm_legalized_flag } #NSM is not legalized
				}
				BUL = { country_event = bftb_bulgaria_factions.04 }
			}
		}
		effect = { #ZVENO COUP
			if = {
				limit = {
					date > 1938.1.1	#Give the player some time
					has_country_flag = BUL_zveno_dissident_event_flag #Zveno has triggered a dissident event
					NOT = { has_country_flag = BUL_zveno_coup_flag } #Zveno CW has not started
					NOT = {	has_country_flag = BUL_zveno_destroyed_flag } #Zveno is not destroyed
					NOT = {	has_country_flag = BUL_zveno_legalized_flag } #Zveno is not legalized
				}
				BUL = { country_event = bftb_bulgaria_factions.05 }
			}
		}
		effect = { #Tsar Boris Dies
			if = { #Force Boris's death in historical
				limit = {
					is_historical_focus_on = yes
					NOT = { has_completed_focus	= BUL_strengthen_the_royal_dictatorship }
					BUL_has_abolished_monarchy = no
					date > 1943.7.30 #Historical date of death is 1943.8.28
					NOT = { has_country_flag = BUL_tsar_boris_is_dead_flag }
					NOT = { has_country_flag = BUL_tsar_boris_assassinated_flag }
				}
				BUL = { country_event = { id = bftb_bulgaria_tsar_boris.2 days = 28 } }
			}
			else_if = { #Attempt to make Boris die if not historical
				limit = {
					is_historical_focus_on = no
					NOT = { has_completed_focus	= BUL_strengthen_the_royal_dictatorship }
					BUL_has_abolished_monarchy = no
					date > 1943.1.1 #Historical date of death is 1943.8.28
					NOT = { has_country_flag = BUL_tsar_boris_is_dead_flag }
					NOT = { has_country_flag = BUL_tsar_boris_assassinated_flag }
				}
				BUL_tsar_boris_may_die_effect = yes
			}
		}

		effect = { #Support the Spanish Coup - Check for a general assigned to volunteers in the SCW fighting for SPA (it cannot be any other side)
			if = {
				limit = {
					has_country_flag = BUL_sent_volunteers_to_SPA_flag
				}
				if = {
					limit = {
						any_unit_leader = {
							is_field_marshal = no
							OR = {
								is_leading_volunteer_group_with_original_country = SPR
								is_leading_volunteer_group = SPR
							}
							NOT = { has_unit_leader_flag = BUL_scw_promotion_flag }
						}
					}
					random_unit_leader = {
						limit = {
							is_field_marshal = no
							OR = {
								is_leading_volunteer_group_with_original_country = SPR
								is_leading_volunteer_group = SPR
							}
						}
						set_unit_leader_flag = BUL_scw_promotion_flag 
					}
				}
			}
		}
	}

	#ROOT is winner, FROM gets annexed.
	on_annex = {
		effect = {
			if = {
				limit = {
					FROM = { tag = KUR}
					ROOT = { tag = TUR }
				}
				TUR = {
					350 = {
						if = {
							limit = {
								is_owned_and_controlled_by = TUR
							}
							add_dynamic_modifier = { modifier = kurdish_agitation }
						}
					}

					353 = {
						if = {
							limit = {
								is_owned_and_controlled_by = TUR
							}
							add_dynamic_modifier = { modifier = kurdish_agitation }
						}
					}

					352 = {

						if = {
							limit = {
								is_owned_and_controlled_by = TUR
							}
							add_dynamic_modifier = { modifier = kurdish_separatism }
						}
					}

					800 = {

						if = {
							limit = {
								is_owned_and_controlled_by = TUR
							}
							add_dynamic_modifier = { modifier = kurdish_separatism }
						}
					}
				}
			}
		}
	}
}