# Kurdish State Pacified
TUR_pacify_kurdish_state_effect = {
	custom_effect_tooltip = TUR_pacify_kurdish_state_effect_tt
	hidden_effect = {
		event_target:TUR_kurdish_state_event_target = {
			if = { 	
				limit = {
					has_dynamic_modifier = { modifier = kurdish_agitation }
				}
				remove_dynamic_modifier = { modifier = kurdish_agitation }
				add_dynamic_modifier = { modifier = separatist_fatigue }
				add_resistance = -20
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = kurdish_separatism }
				}
				remove_dynamic_modifier = { modifier = kurdish_separatism }
				add_dynamic_modifier = { modifier = separatist_fatigue }
				add_resistance = -20
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = kurdish_rebellion }
				}
				remove_dynamic_modifier = { modifier = kurdish_rebellion }
				add_dynamic_modifier = { modifier = separatist_fatigue }
				add_resistance = -20
			}
			if = {
				limit = {
					event_target:TUR_kurdish_state_event_target = { 
						NOT = { is_core_of = TUR }
						compliance > 70
					}
				}
				event_target:TUR_kurdish_state_event_target = { TUR_integrate_kurdish_state_effect = yes }
			}
		}
	}
}

# Kurdish State Effect Downgraded
TUR_placate_kurdish_state_effect = {
	custom_effect_tooltip = TUR_placate_kurdish_state_effect_tt
	hidden_effect = {
		event_target:TUR_kurdish_state_event_target = {
			if = { 	
				limit = {
					has_dynamic_modifier = { modifier = kurdish_agitation }
				}
				remove_dynamic_modifier = { modifier = kurdish_agitation }
				add_dynamic_modifier = { modifier = separatist_fatigue }
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = kurdish_separatism }
				}
				remove_dynamic_modifier = { modifier = kurdish_separatism }
				add_dynamic_modifier = { modifier = kurdish_agitation }
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = kurdish_rebellion }
				}
				remove_dynamic_modifier = { modifier = kurdish_rebellion }
				add_dynamic_modifier = { modifier = kurdish_separatism }
			}
		}
	}
}

# Kurdish State Pacified - Random Target
TUR_pacify_random_kurdish_state_effect = {
	custom_effect_tooltip = TUR_pacify_random_kurdish_state_effect_tt
	hidden_effect = {
		random_owned_state = {
			limit = {
				OR = {
					has_dynamic_modifier = { modifier = kurdish_agitation }
					has_dynamic_modifier = { modifier = kurdish_separatism }
					has_dynamic_modifier = { modifier = kurdish_rebellion }
				}
			}
			save_event_target_as = TUR_kurdish_state_event_target
		}
		event_target:TUR_kurdish_state_event_target = {
			if = { 	
				limit = {
					has_dynamic_modifier = { modifier = kurdish_agitation }
				}
				remove_dynamic_modifier = { modifier = kurdish_agitation }
				add_dynamic_modifier = { modifier = separatist_fatigue }
				add_resistance = -20
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = kurdish_separatism }
				}
				remove_dynamic_modifier = { modifier = kurdish_separatism }
				add_dynamic_modifier = { modifier = separatist_fatigue }
				add_resistance = -20
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = kurdish_rebellion }
				}
				remove_dynamic_modifier = { modifier = kurdish_rebellion }
				add_dynamic_modifier = { modifier = separatist_fatigue }
				add_resistance = -20
			}
			if = {
				limit = {
					event_target:TUR_kurdish_state_event_target = { 
						NOT = { is_core_of = TUR }
						compliance > 70
					}
				}
				event_target:TUR_kurdish_state_event_target = { TUR_integrate_kurdish_state_effect = yes }
			}
		}
	}
}

# Kurdish State Integration Dynamic Effect
TUR_integrate_kurdish_state_effect = {
	custom_effect_tooltip = TUR_integrate_kurdish_state_effect_tt
	hidden_effect = {
		event_target:TUR_kurdish_state_event_target = {
			if = {
				limit = {
					event_target:TUR_kurdish_state_event_target = { 
						NOT = { is_core_of = TUR }
						compliance > 70
					}
				}
				event_target:TUR_kurdish_state_event_target = { add_core_of = TUR }
				remove_dynamic_modifier = { modifier = separatist_fatigue }
				remove_dynamic_modifier = { modifier = kurdish_agitation }
				remove_dynamic_modifier = { modifier = kurdish_separatism }
				remove_dynamic_modifier = { modifier = kurdish_rebellion }
			}
			if = {
				limit = {
					AND = {
						350 = { is_core_of = TUR }
						352 = { is_core_of = TUR }
						353 = { is_core_of = TUR }
						800 = { is_core_of = TUR }
						1287 = { is_core_of = TUR }
						has_idea = TUR_sectarian_woes
					}
				}
				swap_ideas = {
					remove_idea = TUR_sectarian_woes
					add_idea = TUR_sectarian_woes_1
				}
			}
			else_if = {
				limit = {
					AND = {
						350 = { is_core_of = TUR }
						352 = { is_core_of = TUR }
						353 = { is_core_of = TUR }
						800 = { is_core_of = TUR }
						1287 = { is_core_of = TUR }
						has_idea = TUR_sectarian_woes_2
					}
				}
				remove_ideas = TUR_sectarian_woes_2
			}
		}
	}
}

# Kurdish State Integration Forced
TUR_integrate_kurdish_state_forced_effect = {
	custom_effect_tooltip = TUR_integrate_kurdish_state_effect_tt
	hidden_effect = {
		event_target:TUR_kurdish_state_event_target = { 
			add_core_of = TUR

			if = {
				limit = {
					has_dynamic_modifier = {
						modifier = separatist_fatigue
					}
				}
				remove_dynamic_modifier = { modifier = separatist_fatigue }
			}

			if = {
				limit = {
					has_dynamic_modifier = {
						modifier = kurdish_agitation
					}
				}
				remove_dynamic_modifier = { modifier = kurdish_agitation }
			}

			if = {
				limit = {
					has_dynamic_modifier = {
						modifier = kurdish_separatism
					}
				}
				remove_dynamic_modifier = { modifier = kurdish_separatism }
			}

			if = {
				limit = {
					has_dynamic_modifier = {
						modifier = kurdish_rebellion
					}
				}
				remove_dynamic_modifier = { modifier = kurdish_rebellion }
			}
		}
	}
}

# Kurdish State Agitated
TUR_agitate_kurdish_state_effect = {
	custom_effect_tooltip = TUR_agitate_kurdish_state_effect_tt
	hidden_effect = {
		event_target:TUR_kurdish_state_event_target = {
			if = { 	
				limit = {
					has_dynamic_modifier = { modifier = kurdish_rebellion }
				}
				add_resistance = 20
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = kurdish_separatism }
				}
				remove_dynamic_modifier = { modifier = kurdish_separatism }
				add_dynamic_modifier = { modifier = kurdish_rebellion }
				add_resistance = -20
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = kurdish_agitation }
				}
				remove_dynamic_modifier = { modifier = kurdish_agitation }
				add_dynamic_modifier = { modifier = kurdish_separatism }
				add_resistance = -20
			}
		}
	}
}

# Kurdish State Agitated - New Target
TUR_agitate_kurdish_state_random_target_effect = {
	custom_effect_tooltip = TUR_agitate_kurdish_state_effect_tt
	hidden_effect = {
		random_owned_state = {
			limit = {
				OR = {
					has_dynamic_modifier = { modifier = kurdish_agitation }
					has_dynamic_modifier = { modifier = kurdish_separatism }
					has_dynamic_modifier = { modifier = kurdish_rebellion }
				}
			}
			save_event_target_as = TUR_kurdish_state_event_target
		}
		event_target:TUR_kurdish_state_event_target = {
			if = { 	
				limit = {
					has_dynamic_modifier = { modifier = kurdish_rebellion }
				}
				add_resistance = 20
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = kurdish_separatism }
				}
				remove_dynamic_modifier = { modifier = kurdish_separatism }
				add_dynamic_modifier = { modifier = kurdish_rebellion }
				add_resistance = -20
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = kurdish_agitation }
				}
				remove_dynamic_modifier = { modifier = kurdish_agitation }
				add_dynamic_modifier = { modifier = kurdish_separatism }
				add_resistance = -20
			}
		}
	}
}

# Turkish Fundamentalist Influence Spread into State  - Random Target
TUR_fundamentalist_influenced_random_state_effect = {
	custom_effect_tooltip = TUR_fundamentalist_influenced_state_effect_tt
	hidden_effect = {
		random_owned_state = {
			limit = {
				AND = { 
					has_state_flag = TUR_ideological_battleground_state
					NOT = {
						OR = { 
							has_dynamic_modifier = { modifier = kemalist_loyalties }
							has_dynamic_modifier = { modifier = kemalist_schemers }
							has_dynamic_modifier = { modifier = islamist_opposition }
							has_dynamic_modifier = { modifier = islamist_sedition }
							has_dynamic_modifier = { modifier = islamist_insurgency }
							has_dynamic_modifier = { modifier = islamists_placated }
						}
					}
				}
			}
			save_event_target_as = TUR_fundamentalist_state_event_target
		}
		event_target:TUR_fundamentalist_state_event_target = {
			add_dynamic_modifier = { modifier = islamist_opposition }
			clr_state_flag = TUR_ideological_battleground_state
		}
	}
}

# Turkish Fundamentalist State Modifiers Downgraded
TUR_downgrade_fundamentalist_defiance_effect = {
	custom_effect_tooltip = TUR_downgrade_fundamentalist_defiance_effect_tt
	hidden_effect = {	
		event_target:TUR_fundamentalist_state = {
			if = { 	
				limit = {
					has_dynamic_modifier = { modifier = islamist_opposition }
				}
				remove_dynamic_modifier = { modifier = islamist_opposition }
				add_dynamic_modifier = { modifier = islamists_placated }
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = islamist_sedition }
				}
				remove_dynamic_modifier = { modifier = islamist_sedition }
				add_dynamic_modifier = { modifier = islamist_opposition }
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = islamist_insurgency }
				}
				remove_dynamic_modifier = { modifier = islamist_insurgency }
				add_dynamic_modifier = { modifier = islamist_sedition }
			}
		}
	}
}

# Turkish Fundamentalist State Modifiers Upgraded
TUR_upgrade_fundamentalist_defiance_effect = {
	custom_effect_tooltip = TUR_upgrade_fundamentalist_defiance_effect_tt
	hidden_effect = {	
		event_target:TUR_fundamentalist_state = {
			if = { 	
				limit = {
					has_dynamic_modifier = { modifier = islamist_insurgency }
				}
				remove_core_of = TUR
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = islamist_sedition }
				}
				remove_dynamic_modifier = { modifier = islamist_sedition }
				add_dynamic_modifier = { modifier = islamist_insurgency }
			}
			else_if = {
				limit = {
					has_dynamic_modifier = { modifier = islamist_opposition }
				}
				remove_dynamic_modifier = { modifier = islamist_opposition }
				add_dynamic_modifier = { modifier = islamist_sedition }
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = islamists_placated }
				}
				remove_dynamic_modifier = { modifier = islamists_placated }
				add_dynamic_modifier = { modifier = islamist_opposition }
			}
		}
	}
}

# Turkish Fundamentalist State Modifiers Upgraded - Random Target
TUR_upgrade_random_fundamentalist_defiance_effect = {
	custom_effect_tooltip = TUR_upgrade_random_fundamentalist_defiance_effect_tt
	hidden_effect = {	
		random_owned_state = {
			limit = {
				OR = {
					has_dynamic_modifier = { modifier = islamist_opposition }
					has_dynamic_modifier = { modifier = islamist_sedition }
					has_dynamic_modifier = { modifier = islamist_insurgency }
				}
			}
			save_event_target_as = TUR_fundamentalist_state
		}
		event_target:TUR_fundamentalist_state = {
			if = { 	
				limit = {
					has_dynamic_modifier = { modifier = islamist_insurgency }
				}
				remove_core_of = TUR
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = islamist_sedition }
				}
				remove_dynamic_modifier = { modifier = islamist_sedition }
				add_dynamic_modifier = { modifier = islamist_insurgency }
			}
			else_if = {
				limit = {
					has_dynamic_modifier = { modifier = islamist_opposition }
				}
				remove_dynamic_modifier = { modifier = islamist_opposition }
				add_dynamic_modifier = { modifier = islamist_sedition }
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = islamists_placated }
				}
				remove_dynamic_modifier = { modifier = islamists_placated }
				add_dynamic_modifier = { modifier = islamist_opposition }
			}
		}
	}
}

# Turkish Fundamentalist State Placated
TUR_placate_fundamentalist_state_effect = {
	custom_effect_tooltip = TUR_placate_fundamentalist_state_effect_tt
	hidden_effect = {
		event_target:TUR_fundamentalist_state = {
			if = { 	
				limit = {
					has_dynamic_modifier = { modifier = islamist_opposition }
				}
				remove_dynamic_modifier = { modifier = islamist_opposition }
				add_dynamic_modifier = { modifier = islamists_placated }
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = islamist_sedition }
				}
				remove_dynamic_modifier = { modifier = islamist_sedition }
				add_dynamic_modifier = { modifier = islamists_placated }
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = islamist_insurgency }
				}
				remove_dynamic_modifier = { modifier = islamist_insurgency }
				add_dynamic_modifier = { modifier = islamists_placated }
			}
			if = {
				limit = {
					NOT = { is_core_of = TUR }
				}
				add_core_of = TUR
			}
		}
	}
}

# Turkish Fundamentalist State Placated - New Event Target Applied
TUR_placate_fundamentalist_state_random_target_effect = {
	custom_effect_tooltip = TUR_placate_fundamentalist_state_effect_tt
	hidden_effect = {
		random_owned_state = {
			limit = {
				OR = {
					has_dynamic_modifier = { modifier = islamist_opposition }
					has_dynamic_modifier = { modifier = islamist_sedition }
					has_dynamic_modifier = { modifier = islamist_insurgency }
				}
			}
			save_event_target_as = TUR_fundamentalist_state
		}
		event_target:TUR_fundamentalist_state = {
			if = { 	
				limit = {
					has_dynamic_modifier = { modifier = islamist_opposition }
				}
				remove_dynamic_modifier = { modifier = islamist_opposition }
				add_dynamic_modifier = { modifier = islamists_placated }
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = islamist_sedition }
				}
				remove_dynamic_modifier = { modifier = islamist_sedition }
				add_dynamic_modifier = { modifier = islamists_placated }
			}
			else_if = { 	
				limit = {
					has_dynamic_modifier = { modifier = islamist_insurgency }
				}
				remove_dynamic_modifier = { modifier = islamist_insurgency }
				add_dynamic_modifier = { modifier = islamists_placated }
			}
			if = {
				limit = {
					event_target:TUR_fundamentalist_state = { NOT = { is_core_of = TUR } }
				}
				event_target:TUR_fundamentalist_state = { add_core_of = TUR }
			}
		}
	}
}

# Turkish Fundamentalist State Placated - Every State
TUR_placate_fundamentalist_state_all_targets_effect = {
	custom_effect_tooltip = TUR_placate_fundamentalist_state_all_targets_effect_tt
	hidden_effect = {
		every_state = {
			limit = {
				AND = {
					has_dynamic_modifier = { modifier = islamist_insurgency }
					NOT = { is_core_of = TUR }
				}
			}
			add_core_of = TUR
		}
		every_state = {
			limit = {
				THIS = { has_dynamic_modifier = { modifier = islamist_opposition } }
			}
			remove_dynamic_modifier = { modifier = islamist_opposition }
			add_dynamic_modifier = { modifier = islamists_placated }
		}
		every_state = {
			limit = {
				THIS = { has_dynamic_modifier = { modifier = islamist_sedition } }
			}
			remove_dynamic_modifier = { modifier = islamist_sedition }
			add_dynamic_modifier = { modifier = islamists_placated }
		}
		every_state = {
			limit = {
				THIS = { has_dynamic_modifier = { modifier = islamist_insurgency } }
			}
			remove_dynamic_modifier = { modifier = islamist_insurgency }
			add_dynamic_modifier = { modifier = islamists_placated }
		}
	}
}

# Turkish Fundamentalists Empowered
TUR_empower_all_fundamentalists_effect = {
	custom_effect_tooltip = TUR_empower_all_fundamentalists_effect_tt
	hidden_effect = {
		every_owned_state = {
			limit = {
				has_dynamic_modifier = { modifier = islamists_placated }
			}
			remove_dynamic_modifier = { modifier = islamists_placated }
			add_dynamic_modifier = { modifier = devout_islamists }
		}
	}
}

## Turkish Kemalist Officer Power Check
##TUR_kemalist_officer_power_check_effect = {
##	custom_effect_tooltip = TUR_kemalist_officer_power_check_effect_tt
##	hidden_effect = {
##
##	}
##}

# Turkish Kemalist Loyalty and Power Check
TUR_kemalist_loyalty_and_power_update_effect = {
	custom_effect_tooltip = TUR_kemalist_loyalty_and_power_update_effect_tt
	hidden_effect = {
		TUR_kemalist_refresh_effect = yes
		if = {
			limit = {
				check_variable = { var = TUR_kemalist_officers_loyalty value = 3 compare = greater_than }
			}
			set_variable = { var = TUR_kemalist_officers_loyalty value = 3 }
		}
		if = {
			limit = {
				check_variable = { var = TUR_kemalist_officers_loyalty value = 1 compare = less_than }
			}
			set_variable = { var = TUR_kemalist_officers_loyalty value = 1 }
		}
		if = { #powerless
			limit = {
				check_variable = { var = TUR_kemalist_officers_loyalty value = 1 compare = equals }
				check_variable = { var = TUR_kemalist_power_variable value = 2 compare = less_than_or_equals }
				NOT = { has_idea = TUR_kemalist_army_officers_minimal_power_disloyal }
			}
			swap_ideas = {
				remove_idea = var:current_officer_spirit
				add_idea = TUR_kemalist_army_officers_minimal_power_disloyal
			}
		}
		else_if = { 
			limit = {
				check_variable = { var = TUR_kemalist_officers_loyalty value = 2 compare = equals }
				check_variable = { var = TUR_kemalist_power_variable value = 2 compare = less_than_or_equals }
				NOT = { has_idea = TUR_kemalist_army_officers_minimal_power_neutral }
			}
			swap_ideas = {
				remove_idea = var:current_officer_spirit
				add_idea = TUR_kemalist_army_officers_minimal_power_neutral
			}
		}
		else_if = { 
			limit = {
				check_variable = { var = TUR_kemalist_officers_loyalty value = 3 compare = equals }
				check_variable = { var = TUR_kemalist_power_variable value = 2 compare = less_than_or_equals }
				NOT = { has_idea = TUR_kemalist_army_officers_minimal_power_loyal }
			}
			swap_ideas = {
				remove_idea = var:current_officer_spirit
				add_idea = TUR_kemalist_army_officers_minimal_power_loyal
			}
		}
		else_if = { #reduced power
			limit = {
				check_variable = { var = TUR_kemalist_officers_loyalty value = 1 compare = equals }
				OR = {
					check_variable = { var = TUR_kemalist_power_variable value = 3 compare = equals }
					check_variable = { var = TUR_kemalist_power_variable value = 4 compare = equals }
				}
				NOT = { has_idea = TUR_kemalist_army_officers_decreased_power_disloyal }
			}
			swap_ideas = {
				remove_idea = var:current_officer_spirit
				add_idea = TUR_kemalist_army_officers_decreased_power_disloyal
			}
		}
		else_if = { 
			limit = {
				check_variable = { var = TUR_kemalist_officers_loyalty value = 2 compare = equals }
				OR = {
					check_variable = { var = TUR_kemalist_power_variable value = 3 compare = equals }
					check_variable = { var = TUR_kemalist_power_variable value = 4 compare = equals }
				}
				NOT = { has_idea = TUR_kemalist_army_officers_decreased_power_neutral }
			}
			swap_ideas = {
				remove_idea = var:current_officer_spirit
				add_idea = TUR_kemalist_army_officers_decreased_power_neutral
			}
		}
		else_if = { 
			limit = {
				check_variable = { var = TUR_kemalist_officers_loyalty value = 3 compare = equals }
				OR = {
					check_variable = { var = TUR_kemalist_power_variable value = 3 compare = equals }
					check_variable = { var = TUR_kemalist_power_variable value = 4 compare = equals }
				}
				NOT = { has_idea = TUR_kemalist_army_officers_decreased_power_loyal }
			}
			swap_ideas = {
				remove_idea = var:current_officer_spirit
				add_idea = TUR_kemalist_army_officers_decreased_power_loyal
			}
		}
		else_if = { #limited power
			limit = {
				check_variable = { var = TUR_kemalist_officers_loyalty value = 1 compare = equals }
				OR = {
					check_variable = { var = TUR_kemalist_power_variable value = 5 compare = equals }
					check_variable = { var = TUR_kemalist_power_variable value = 6 compare = equals }
				}
				NOT = { has_idea = TUR_kemalist_army_officers_limited_power_disloyal }
			}
			swap_ideas = {
				remove_idea = var:current_officer_spirit
				add_idea = TUR_kemalist_army_officers_limited_power_disloyal
			}
		}
		else_if = { 
			limit = {
				check_variable = { var = TUR_kemalist_officers_loyalty value = 2 compare = equals }
				OR = {
					check_variable = { var = TUR_kemalist_power_variable value = 5 compare = equals }
					check_variable = { var = TUR_kemalist_power_variable value = 6 compare = equals }
				}
				NOT = { has_idea = TUR_kemalist_army_officers_limited_power_neutral }
			}
			swap_ideas = {
				remove_idea = var:current_officer_spirit
				add_idea = TUR_kemalist_army_officers_limited_power_neutral
			}
		}
		else_if = { 
			limit = {
				check_variable = { var = TUR_kemalist_officers_loyalty value = 3 compare = equals }
				OR = {
					check_variable = { var = TUR_kemalist_power_variable value = 5 compare = equals }
					check_variable = { var = TUR_kemalist_power_variable value = 6 compare = equals }
				}
				NOT = { has_idea = TUR_kemalist_army_officers_extended_power_loyal }
			}
			swap_ideas = {
				remove_idea = var:current_officer_spirit
				add_idea = TUR_kemalist_army_officers_extended_power_loyal
			}
		}
		else_if = { #extended powers
			limit = {
				check_variable = { var = TUR_kemalist_officers_loyalty value = 1 compare = equals }
				OR = {
					check_variable = { var = TUR_kemalist_power_variable value = 7 compare = equals }
					check_variable = { var = TUR_kemalist_power_variable value = 8 compare = equals }
				}
				NOT = { has_idea = TUR_kemalist_army_officers_extended_power_disloyal }
			}
			swap_ideas = {
				remove_idea = var:current_officer_spirit
				add_idea = TUR_kemalist_army_officers_extended_power_disloyal
			}
		}
		else_if = { 
			limit = {
				check_variable = { var = TUR_kemalist_officers_loyalty value = 2 compare = equals }
				OR = {
					check_variable = { var = TUR_kemalist_power_variable value = 7 compare = equals }
					check_variable = { var = TUR_kemalist_power_variable value = 8 compare = equals }
				}
				NOT = { has_idea = TUR_kemalist_army_officers_extended_power_neutral }
			}
			swap_ideas = {
				remove_idea = var:current_officer_spirit
				add_idea = TUR_kemalist_army_officers_extended_power_neutral
			}
		}
		else_if = { 
			limit = {
				check_variable = { var = TUR_kemalist_officers_loyalty value = 3 compare = equals }
				OR = {
					check_variable = { var = TUR_kemalist_power_variable value = 7 compare = equals }
					check_variable = { var = TUR_kemalist_power_variable value = 8 compare = equals }
				}
				NOT = { has_idea = TUR_kemalist_army_officers_extended_power_loyal }
			}
			swap_ideas = {
				remove_idea = var:current_officer_spirit
				add_idea = TUR_kemalist_army_officers_extended_power_loyal
			}
		}
		else_if = { #unlimited powah!
			limit = {
				check_variable = { var = TUR_kemalist_officers_loyalty value = 1 compare = equals }
				check_variable = { var = TUR_kemalist_power_variable value = 8 compare = greater_than_or_equals }
				NOT = { has_idea = TUR_kemalist_army_officers_powerful_disloyal }
			}
			swap_ideas = {
				remove_idea = var:current_officer_spirit
				add_idea = TUR_kemalist_army_officers_powerful_disloyal
			}
		}
		else_if = { 
			limit = {
				check_variable = { var = TUR_kemalist_officers_loyalty value = 2 compare = equals }
				check_variable = { var = TUR_kemalist_power_variable value = 8 compare = greater_than_or_equals }
				NOT = { has_idea = TUR_kemalist_army_officers_powerful_neutral }
			}
			swap_ideas = {
				remove_idea = var:current_officer_spirit
				add_idea = TUR_kemalist_army_officers_powerful_neutral
			}
		}
		else_if = { 
			limit = {
				check_variable = { var = TUR_kemalist_officers_loyalty value = 3 compare = equals }
				check_variable = { var = TUR_kemalist_power_variable value = 8 compare = greater_than_or_equals }
				NOT = { has_idea = TUR_kemalist_army_officers_powerful_loyal }
			}
			swap_ideas = {
				remove_idea = var:current_officer_spirit
				add_idea = TUR_kemalist_army_officers_powerful_loyal
			}
		}
	}
}

# Turkish Kemalist Officer Spirit Refresh
TUR_kemalist_refresh_effect = {
	hidden_effect = {
		if = { 
			limit = {
				ROOT = { has_idea = TUR_kemalist_army_officers_minimal_power_loyal }
			}
			set_temp_variable = { current_officer_spirit = token:TUR_kemalist_army_officers_minimal_power_loyal }
		}
		if = { 
			limit = {
				ROOT = { has_idea = TUR_kemalist_army_officers_minimal_power_neutral }
			}
			set_temp_variable = { current_officer_spirit = token:TUR_kemalist_army_officers_minimal_power_neutral }
		}
		if = { 
			limit = {
				ROOT = { has_idea = TUR_kemalist_army_officers_minimal_power_disloyal }
			}
			set_temp_variable = { current_officer_spirit = token:TUR_kemalist_army_officers_minimal_power_disloyal }
		}
		if = { 
			limit = {
				ROOT = { has_idea = TUR_kemalist_army_officers_decreased_power_loyal }
			}
			set_temp_variable = { current_officer_spirit = token:TUR_kemalist_army_officers_decreased_power_loyal }
		}
		if = { 
			limit = {
				ROOT = { has_idea = TUR_kemalist_army_officers_decreased_power_neutral }
			}
			set_temp_variable = { current_officer_spirit = token:TUR_kemalist_army_officers_decreased_power_neutral }
		}
		if = { 
			limit = {
				ROOT = { has_idea = TUR_kemalist_army_officers_decreased_power_disloyal }
			}
			set_temp_variable = { current_officer_spirit = token:TUR_kemalist_army_officers_decreased_power_disloyal }
		}
		if = { 
			limit = {
				ROOT = { has_idea = TUR_kemalist_army_officers_limited_power_loyal }
			}
			set_temp_variable = { current_officer_spirit = token:TUR_kemalist_army_officers_limited_power_loyal }
		}
		if = { 
			limit = {
				ROOT = { has_idea = TUR_kemalist_army_officers_limited_power_neutral }
			}
			set_temp_variable = { current_officer_spirit = token:TUR_kemalist_army_officers_limited_power_neutral }
		}
		if = { 
			limit = {
				ROOT = { has_idea = TUR_kemalist_army_officers_limited_power_disloyal }
			}
			set_temp_variable = { current_officer_spirit = token:TUR_kemalist_army_officers_limited_power_disloyal }
		}
		if = { 
			limit = {
				ROOT = { has_idea = TUR_kemalist_army_officers_extended_power_loyal }
			}
			set_temp_variable = { current_officer_spirit = token:TUR_kemalist_army_officers_extended_power_loyal }
		}
		if = { 
			limit = {
				ROOT = { has_idea = TUR_kemalist_army_officers_extended_power_neutral }
			}
			set_temp_variable = { current_officer_spirit = token:TUR_kemalist_army_officers_extended_power_neutral }
		}
		if = { 
			limit = {
				ROOT = { has_idea = TUR_kemalist_army_officers_extended_power_disloyal }
			}
			set_temp_variable = { current_officer_spirit = token:TUR_kemalist_army_officers_extended_power_disloyal }
		}
		if = { 
			limit = {
				ROOT = { has_idea = TUR_kemalist_army_officers_powerful_loyal }
			}
			set_temp_variable = { current_officer_spirit = token:TUR_kemalist_army_officers_powerful_loyal }
		}
		if = { 
			limit = {
				ROOT = { has_idea = TUR_kemalist_army_officers_powerful_neutral }
			}
			set_temp_variable = { current_officer_spirit = token:TUR_kemalist_army_officers_powerful_neutral }
		}
		if = { 
			limit = {
				ROOT = { has_idea = TUR_kemalist_army_officers_powerful_disloyal }
			}
			set_temp_variable = { current_officer_spirit = token:TUR_kemalist_army_officers_powerful_disloyal }
		}
	}
}

# Turkish Kemalist Influence Spread into State
TUR_kemalist_influenced_state_effect = {
	custom_effect_tooltip = TUR_kemalist_influenced_state_effect_tt
	hidden_effect = {
		event_target:TUR_kemalist_state_event_target = {
			add_dynamic_modifier = { modifier = kemalist_loyalties }
			clr_state_flag = TUR_ideological_battleground_state
		}
		if = {
			limit = {
				check_variable = { var = TUR_kemalist_officers_loyalty value = 3 compare = less_than }
			}
			add_to_variable = { var = TUR_kemalist_officers_loyalty value = 1 }
		}
		add_to_variable = { var = TUR_kemalist_power_variable value = 1 }
		#TUR_kemalist_officer_power_check_effect = yes
		TUR_kemalist_loyalty_and_power_update_effect = yes
	}
}

# Turkish Kemalist Influence Spread into State  - Random Target
TUR_kemalist_influenced_random_state_effect = {
	custom_effect_tooltip = TUR_kemalist_influenced_state_effect_tt
	hidden_effect = {
		random_owned_state = {
			limit = {
				AND = { 
					has_state_flag = TUR_ideological_battleground_state
					NOT = {
						OR = { 
							has_dynamic_modifier = { modifier = kemalist_loyalties }
							has_dynamic_modifier = { modifier = kemalist_schemers }
							has_dynamic_modifier = { modifier = islamist_opposition }
							has_dynamic_modifier = { modifier = islamist_sedition }
							has_dynamic_modifier = { modifier = islamist_insurgency }
							has_dynamic_modifier = { modifier = islamists_placated }
						}
					}
				}
			}
			save_event_target_as = TUR_kemalist_state_event_target
		}
		event_target:TUR_kemalist_state_event_target = {
			add_dynamic_modifier = { modifier = kemalist_loyalties }
			clr_state_flag = TUR_ideological_battleground_state
		}
		if = {
			limit = {
				check_variable = { var = TUR_kemalist_officers_loyalty value = 3 compare = less_than }
			}
			add_to_variable = { var = TUR_kemalist_officers_loyalty value = 1 }
		}
		add_to_variable = { var = TUR_kemalist_power_variable value = 1 }
		TUR_kemalist_loyalty_and_power_update_effect = yes
	}
}

# Turkish Kemalist Influence Spread into State  - Random Target
TUR_hostile_kemalists_influenced_random_state_effect = {
	custom_effect_tooltip = TUR_hostile_kemalists_influenced_state_effect_tt
	hidden_effect = {
		random_owned_state = {
			limit = {
				AND = { 
					has_state_flag = TUR_ideological_battleground_state
					NOT = {
						OR = { 
							has_dynamic_modifier = { modifier = kemalist_loyalties }
							has_dynamic_modifier = { modifier = kemalist_schemers }
							has_dynamic_modifier = { modifier = islamist_opposition }
							has_dynamic_modifier = { modifier = islamist_sedition }
							has_dynamic_modifier = { modifier = islamist_insurgency }
							has_dynamic_modifier = { modifier = islamists_placated }
						}
					}
				}
			}
			save_event_target_as = TUR_kemalist_state_event_target
		}
		event_target:TUR_kemalist_state_event_target = {
			add_dynamic_modifier = { modifier = kemalist_schemers }
			clr_state_flag = TUR_ideological_battleground_state
		}
		add_to_variable = { var = TUR_kemalist_power_variable value = 1 }
		TUR_kemalist_loyalty_and_power_update_effect = yes
	}
}

# Turkish Kemalist Influence Spread into State
TUR_hostile_kemalists_influenced_state_effect = {
	custom_effect_tooltip = TUR_hostile_kemalists_influenced_state_effect_tt
	hidden_effect = {
		event_target:TUR_kemalist_state_event_target = {
			add_dynamic_modifier = { modifier = kemalist_schemers }
			clr_state_flag = TUR_ideological_battleground_state
		}
		add_to_variable = { var = TUR_kemalist_power_variable value = 1 }
		TUR_kemalist_loyalty_and_power_update_effect = yes
	}
}

# Turkish Kemalists Turn Hostile
TUR_kemalist_turn_hostile_effect = {
	custom_effect_tooltip = TUR_kemalist_turn_hostile_effect_tt
	hidden_effect = {
		every_owned_state = {
			limit = {
				has_dynamic_modifier = { modifier = kemalist_loyalties }
			}
			remove_dynamic_modifier = { modifier = kemalist_loyalties }
			add_dynamic_modifier = { modifier = kemalist_schemers }
		}
		set_variable = { var = TUR_kemalist_officers_loyalty value = 1 }
		#TUR_kemalist_officer_power_check_effect = yes
		TUR_kemalist_loyalty_and_power_update_effect = yes
	}
}

# Turkish Kemalists Realise You Aren't So Bad
TUR_kemalist_turn_ally_effect = {
	custom_effect_tooltip = TUR_kemalist_turn_ally_effect_tt
	hidden_effect = {
		every_owned_state = {
			limit = {
				has_dynamic_modifier = { modifier = kemalist_schemers }
			}
			remove_dynamic_modifier = { modifier = kemalist_schemers }
			add_dynamic_modifier = { modifier = kemalist_loyalties }
		}
		set_variable = { var = TUR_kemalist_officers_loyalty value = 2 }
		#TUR_kemalist_officer_power_check_effect = yes
		TUR_kemalist_loyalty_and_power_update_effect = yes
	}
}

# Worsen Ataturk's Health
TUR_worsen_ataturks_health_effect = {
	custom_effect_tooltip = TUR_worsen_ataturks_health_effect_tt
	hidden_effect = {
		if = {
			limit = {
				NOT = { has_variable = TUR_ataturk_sickness_factor_var }
				has_country_leader_with_trait = father_of_the_turks
			}
			set_variable = { var = TUR_ataturk_sickness_factor_var value = 1 }
			swap_ruler_traits = { remove = father_of_the_turks add = father_of_the_turks_1 }
		}
		if = {
			limit = {
				check_variable = { var = TUR_ataturk_sickness_factor_var value = 1 compare = equals }
				has_country_leader_with_trait = father_of_the_turks_1
			}
			add_to_variable = { var = TUR_ataturk_sickness_factor_var value = 1 }
			swap_ruler_traits = { remove = father_of_the_turks_1 add = father_of_the_turks_2 }
		}
		else_if = {
			limit = {
				check_variable = { var = TUR_ataturk_sickness_factor_var value = 2 compare = equals }
				has_country_leader_with_trait = father_of_the_turks_2
			}
			swap_ruler_traits = { remove = father_of_the_turks_2 add = father_of_the_turks_3 }
			add_to_variable = { var = TUR_ataturk_sickness_factor_var value = 1 }
		}
		else_if = {
			limit = {
				check_variable = { var = TUR_ataturk_sickness_factor_var value = 3 compare = equals }
				has_country_leader_with_trait = father_of_the_turks_3
			}
			swap_ruler_traits = { remove = father_of_the_turks_3 add = father_of_the_turks_4 }
			add_to_variable = { var = TUR_ataturk_sickness_factor_var value = 1 }
		}
		else_if = {
			limit = {
				check_variable = { var = TUR_ataturk_sickness_factor_var value = 4 compare = equals }
			}
			add_country_leader_trait = infirm
			add_to_variable = { var = TUR_ataturk_treatment_cost_var value = 250 }
			if = {
				limit = {
					TUR_mustafa_kemal_ataturk = { is_unit_leader = yes }
				}
				TUR_mustafa_kemal_ataturk = { remove_unit_leader_role = yes }
			}
		}
	}
}

#Apply appropriate cosmetic tag so that 3D models change based on ideology
TUR_set_appropriate_cosmetic_tag = {
	if = {
		limit = { original_tag = TUR }
		if = {
			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 = {
				set_cosmetic_tag = OTT_UNIFIED_neutrality
			}
		}
		else_if = {
			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 = {
				set_cosmetic_tag = OTT_SULTANATE_neutrality
			}
		}
		else_if = {
			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 = {
				set_cosmetic_tag = TUR_PROVISIONARY_neutrality
			}
		}
		else_if = {
			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 = {
				set_cosmetic_tag = TUR_GREATER_TURKEY_neutrality
			}
		}
		else_if = {
			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 = {
				set_cosmetic_tag = TRN_neutrality
			}
		}
	}
}

TUR_remove_state_modifier_effect = {
	if = {
		limit = {
			has_dynamic_modifier = { modifier = kurdish_agitation }
		}
		remove_dynamic_modifier = { modifier = kurdish_agitation }
		set_state_flag = TUR_kurdish_state_conquered
	}
	else_if = {
		limit = {
			has_dynamic_modifier = { modifier = kurdish_separatism }
		}
		remove_dynamic_modifier = { modifier = kurdish_separatism }
		set_state_flag = TUR_kurdish_state_conquered
	}
	else_if = {
		limit = {
			has_dynamic_modifier = { modifier = kurdish_rebellion }
		}
		remove_dynamic_modifier = { modifier = kurdish_rebellion }
		set_state_flag = TUR_kurdish_state_conquered
	}
	else_if = {
		limit = {
			has_dynamic_modifier = { modifier = separatist_fatigue }
		}
		remove_dynamic_modifier = { modifier = separatist_fatigue }
		set_state_flag = TUR_kurdish_state_conquered
	}
	if = {
		limit = {
			has_dynamic_modifier = { modifier = islamist_opposition }
		}
		remove_dynamic_modifier = { modifier = islamist_opposition }
		set_state_flag = TUR_traditionalist_state_conquered
	}
	else_if = {
		limit = {
			has_dynamic_modifier = { modifier = islamist_sedition }
		}
		remove_dynamic_modifier = { modifier = islamist_sedition }
		set_state_flag = TUR_traditionalist_state_conquered
	}
	else_if = {
		limit = {
			has_dynamic_modifier = { modifier = islamist_insurgency }
		}
		remove_dynamic_modifier = { modifier = islamist_insurgency }
		set_state_flag = TUR_traditionalist_state_conquered
	}
	else_if = {
		limit = {
			has_dynamic_modifier = { modifier = islamists_placated }
		}
		remove_dynamic_modifier = { modifier = islamists_placated }
		set_state_flag = TUR_traditionalist_state_conquered
	}
	if = {
		limit = {
			has_dynamic_modifier = { modifier = kemalist_loyalties }
		}
		remove_dynamic_modifier = { modifier = kemalist_loyalties }
		set_state_flag = TUR_loyal_kemalist_state_conquered
	}
	if = {
		limit = {
			has_dynamic_modifier = { modifier = turanist_assimilation }
		}
		remove_dynamic_modifier = { modifier = turanist_assimilation }
		set_state_flag = TUR_turanist_state_conquered
	}
	if = {
		limit = {
			has_dynamic_modifier = { modifier = kemalist_schemers }
		}
		remove_dynamic_modifier = { modifier = kemalist_schemers }
	}
	if = {
		limit = {
			has_dynamic_modifier = { modifier = conscription_exemptions_granted }
		}
		remove_dynamic_modifier = { modifier = conscription_exemptions_granted }
	}
}
TUR_restore_dynamic_modifiers_effect = {
	if = {
		limit = {
			has_state_flag = TUR_kurdish_state_conquered
		}
		add_dynamic_modifier = { modifier = separatist_fatigue }
		clr_state_flag = TUR_kurdish_state_conquered
	}
	if = {
		limit = {
			has_state_flag = TUR_traditionalist_state_conquered
		}
		add_dynamic_modifier = { modifier = islamists_placated }
		clr_state_flag = TUR_traditionalist_state_conquered
	}
	if = {
		limit = {
			has_state_flag = TUR_loyal_kemalist_state_conquered
		}
		add_dynamic_modifier = { modifier = kemalist_loyalties }
		clr_state_flag = TUR_loyal_kemalist_state_conquered
	}
	if = {
		limit = {
			has_state_flag = TUR_turanist_state_conquered
		}
		add_dynamic_modifier = { modifier = turanist_assimilation }
		clr_state_flag = TUR_turanist_state_conquered
	}
}