########### GLOBAL CONTROL SCRIPTED EFFECTS ###########
nkmp_misc_enable_ai_scripted_effect = {
	every_other_country = {
		if = {
			limit = {
				is_ai = yes
			}
			remove_ideas = nkmp_ai_idea
		}
	}
}

nkmp_misc_disable_ai_scripted_effect = {
	every_other_country = {
		if = {
			limit = {
				is_ai = yes
			}
			add_ideas = nkmp_ai_idea
		}
	}
}

nkmp_global_disable_energy_scripted_effect = {
	if = {
		limit = {
			has_global_flag = nkmp_flg_global_MD_Mode
		}
		every_country = {
			nkmp_md_energy_disabled_scripted_effect = yes
		}
	}
	else = {
		every_country = {
			nkmp_energy_disabled_scripted_effect = yes
		}
	}
}

nkmp_global_enable_energy_scripted_effect = {
	if = {
		limit = {
			has_global_flag = nkmp_flg_global_MD_Mode
		}
		every_country = {
			nkmp_md_energy_enabled_scripted_effect = yes
		}
	}
	else = {
		every_country = {
			nkmp_energy_enabled_scripted_effect = yes
		}
	}
}

nkmp_remove_all_factions_scripted_effect = {
	every_country = {
		limit = {
			is_faction_leader = yes
		}
		dismantle_faction = yes
	}
}

nkmp_forbid_factions_scripted_effect = {
	every_country = {
		set_rule = {
			can_create_factions = no
		}
	}
}

nkmp_allow_factions_scripted_effect = {
	every_country = {
		set_rule = {
			can_create_factions = yes
		}
	}
}

nkmp_release_all_subjects_scripted_effect = {
	every_country = {
		limit = {
			is_subject = yes
		}
		OVERLORD = {
			set_autonomy = {
				target = PREV
				autonomy_state = autonomy_free
			}
		}
	}
}

nkmp_revoke_guarantees_scripted_effect = {
	custom_effect_tooltip = nkmp_remove_guarantees_desc_TT
	hidden_effect = {
		every_country = {
			THIS = {
				every_other_country = {
					diplomatic_relation = {
						country = PREV
						relation = guarantee
						active = no
					}
				}
			}
		}
	}
}

nkmp_forbid_guarantees_scripted_effect = {
	add_ideas = nkmp_forbid_guarantees_idea
}

nkmp_allow_guarantees_scripted_effect = {
	remove_ideas = nkmp_forbid_guarantees_idea
}

nkmp_forbid_volunteers_scripted_effect = {
	every_country = {
		limit = {
			is_ai = yes
		}
		add_ideas = nkmp_forbid_volunteers_idea
	}
}

nkmp_allow_volunteers_scripted_effect = {
	every_country = {
		limit = {
			is_ai = yes
			has_idea = nkmp_forbid_volunteers_idea
		}
		remove_ideas = nkmp_forbid_volunteers_idea
	}
}

nkmp_forbid_lend_lease_scripted_effect = {
	every_country = {
		limit = {
			is_ai = yes
		}
		add_ideas = nkmp_forbid_lend_lease_idea
	}
}

nkmp_allow_lend_lease_scripted_effect = {
	every_country = {
		limit = {
			is_ai = yes
			has_idea = nkmp_forbid_lend_lease_idea
		}
		remove_ideas = nkmp_forbid_lend_lease_idea
	}
}

nkmp_remove_all_dmz_scripted_effect = {
	every_state = {
		limit = {
			is_demilitarized_zone = yes
		}
		set_demilitarized_zone = no
	}
}

nkmp_max_all_infrastructure_scripted_effect = {
	custom_effect_tooltip = nkmp_startup_global_max_infrastructure_desc_TT
	hidden_effect = {
		nkmp_max_infra_every_state_scripted_effect = yes
	}
}

nkmp_stop_all_wars_scripted_effect = {
	custom_effect_tooltip = nkmp_stop_all_wars_desc_TT
	hidden_effect = {
		every_country = {
			limit = {
				has_war = yes
			}
			THIS = {
				every_other_country = {
					limit = {
						has_war_with = PREV
					}
					white_peace = PREV
				}
			}
		}
	}
}

nkmp_every_country_research_all_scripted_effect = {
	every_country = {
		custom_effect_tooltip = nkmp_research_all_TT
		hidden_effect = {
			nkmp_research_all_scripted_effect = yes
		}
	}
}

nkmp_every_country_delete_units_scripted_effect = {
	custom_effect_tooltip = nkmp_every_country_delete_units_TT
	hidden_effect = {
		every_country = {
			delete_unit = {
				disband = yes
			}
		}
	}
}

nkmp_every_other_country_delete_units_scripted_effect = {
	custom_effect_tooltip = nkmp_every_other_country_delete_units_TT
	hidden_effect = {
		every_other_country = {
			delete_unit = {
				disband = yes
			}
		}
	}
}

nkmp_misc_fix_lag_scripted_effect = {
	# India Doesn't get AI IDEAS
	if = {
		limit = {
			country_exists = RAJ
		}
		RAJ = {
			if = {
				limit = {
					country_exists = BHU
				}
				annex_country = {
					target = BHU
				}
			}
			if = {
				limit = {
					country_exists = NEP
				}
				annex_country = {
					target = NEP
				}
			}
			hidden_effect = {
				if = {
					limit = {
						country_exists = BHU
					}
					every_state = {
						limit = {
							is_core_of = BHU
						}
						add_core_of = RAJ
					}
				}
				if = {
					limit = {
						country_exists = NEP
					}
					every_state = {
						limit = {
							is_core_of = NEP
						}
						add_core_of = RAJ
					}
				}
			}
		}
	}
	# AI IDEAS - Honduras
	if = {
		limit = {
			country_exists = HON
		}
		HON = {
			if = {
				limit = {
					country_exists = HON
				}
				add_ideas = nkmp_ai_idea
				add_ideas = undisturbed_isolation
				add_ideas = disarmed_nation
				set_research_slots = 0
			}
			if = {
				limit = {
					country_exists = GUA
				}
				annex_country = {
					target = GUA
				}
			}
			if = {
				limit = {
					country_exists = ELS
				}
				annex_country = {
					target = ELS
				}
			}
			if = {
				limit = {
					country_exists = NIC
				}
				annex_country = {
					target = NIC
				}
			}
			if = {
				limit = {
					country_exists = COS
				}
				annex_country = {
					target = COS
				}
			}
			if = {
				limit = {
					country_exists = PAN
				}
				annex_country = {
					target = PAN
				}
			}
			if = {
				limit = {
					country_exists = CUB
				}
				annex_country = {
					target = CUB
				}
			}
			if = {
				limit = {
					country_exists = HAI
				}
				annex_country = {
					target = HAI
				}
			}
			if = {
				limit = {
					country_exists = DOM
				}
				annex_country = {
					target = DOM
				}
			}
			hidden_effect = {
				if = {
					limit = {
						country_exists = GUA
					}
					every_state = {
						limit = {
							is_core_of = GUA
						}
						add_core_of = HON
					}
				}
				if = {
					limit = {
						country_exists = ELS
					}
					every_state = {
						limit = {
							is_core_of = ELS
						}
						add_core_of = HON
					}
				}
				if = {
					limit = {
						country_exists = NIC
					}
					every_state = {
						limit = {
							is_core_of = NIC
						}
						add_core_of = HON
					}
				}
				if = {
					limit = {
						country_exists = COS
					}
					every_state = {
						limit = {
							is_core_of = COS
						}
						add_core_of = HON
					}
				}
				if = {
					limit = {
						country_exists = PAN
					}
					every_state = {
						limit = {
							is_core_of = PAN
						}
						add_core_of = HON
					}
				}
				if = {
					limit = {
						country_exists = CUB
					}
					every_state = {
						limit = {
							is_core_of = CUB
						}
						add_core_of = HON
					}
				}
				if = {
					limit = {
						country_exists = HAI
					}
					every_state = {
						limit = {
							is_core_of = HAI
						}
						add_core_of = HON
					}
				}
				if = {
					limit = {
						country_exists = DOM
					}
					every_state = {
						limit = {
							is_core_of = DOM
						}
						add_core_of = HON
					}
				}
			}
		}
	}
	# AI IDEAS - Brazil
	if = {
		limit = {
			country_exists = BRA
		}
		BRA = {
			if = {
				limit = {
					country_exists = BRA
				}
				add_ideas = nkmp_ai_idea
				add_ideas = undisturbed_isolation
				add_ideas = disarmed_nation
				set_research_slots = 0
			}
			if = {
				limit = {
					country_exists = VEN
				}
				annex_country = {
					target = VEN
				}
			}
			if = {
				limit = {
					country_exists = COL
				}
				annex_country = {
					target = COL
				}
			}
			if = {
				limit = {
					country_exists = PRU
				}
				annex_country = {
					target = PRU
				}
			}
			if = {
				limit = {
					country_exists = ECU
				}
				annex_country = {
					target = ECU
				}
			}
			if = {
				limit = {
					country_exists = BOL
				}
				annex_country = {
					target = BOL
				}
			}
			if = {
				limit = {
					country_exists = CHL
				}
				annex_country = {
					target = CHL
				}
			}
			if = {
				limit = {
					country_exists = ARG
				}
				annex_country = {
					target = ARG
				}
			}
			if = {
				limit = {
					country_exists = PAR
				}
				annex_country = {
					target = PAR
				}
			}
			if = {
				limit = {
					country_exists = URG
				}
				annex_country = {
					target = URG
				}
			}
			hidden_effect = {
				if = {
					limit = {
						country_exists = VEN
					}
					every_state = {
						limit = {
							is_core_of = VEN
						}
						add_core_of = BRA
					}
				}
				if = {
					limit = {
						country_exists = COL
					}
					every_state = {
						limit = {
							is_core_of = COL
						}
						add_core_of = BRA
					}
				}
				if = {
					limit = {
						country_exists = PRU
					}
					every_state = {
						limit = {
							is_core_of = PRU
						}
						add_core_of = BRA
					}
				}
				if = {
					limit = {
						country_exists = ECU
					}
					every_state = {
						limit = {
							is_core_of = ECU
						}
						add_core_of = BRA
					}
				}
				if = {
					limit = {
						country_exists = BOL
					}
					every_state = {
						limit = {
							is_core_of = BOL
						}
						add_core_of = BRA
					}
				}
				if = {
					limit = {
						country_exists = CHL
					}
					every_state = {
						limit = {
							is_core_of = CHL
						}
						add_core_of = BRA
					}
				}
				if = {
					limit = {
						country_exists = ARG
					}
					every_state = {
						limit = {
							is_core_of = ARG
						}
						add_core_of = BRA
					}
				}
				if = {
					limit = {
						country_exists = PAR
					}
					every_state = {
						limit = {
							is_core_of = PAR
						}
						add_core_of = BRA
					}
				}
				if = {
					limit = {
						country_exists = URG
					}
					every_state = {
						limit = {
							is_core_of = URG
						}
						add_core_of = BRA
					}
				}
			}
		}
	}
	# France Doesn't Get AI IDEAS
	if = {
		limit = {
			country_exists = FRA
		}
		FRA = {
			if = {
				limit = {
					country_exists = LIB
				}
				annex_country = {
					target = LIB
				}
			}
			hidden_effect = {
				if = {
					limit = {
						country_exists = LIB
					}
					every_state = {
						limit = {
							is_core_of = LIB
						}
						add_core_of = FRA
					}
				}
			}
		}
	}
	# Saudi Arabia Doesn't Get AI IDEAS
	if = {
		limit = {
			country_exists = SAU
		}
		SAU = {
			if = {
				limit = {
					country_exists = YEM
				}
				annex_country = {
					target = YEM
				}
			}
			if = {
				limit = {
					country_exists = OMA
				}
				annex_country = {
					target = OMA
				}
			}
			hidden_effect = {
				if = {
					limit = {
						country_exists = YEM
					}
					every_state = {
						limit = {
							is_core_of = YEM
						}
						add_core_of = SAU
					}
				}
				if = {
					limit = {
						country_exists = OMA
					}
					every_state = {
						limit = {
							is_core_of = OMA
						}
						add_core_of = SAU
					}
				}
			}
		}
	}
	if = {
		limit = {
			country_exists = HON
		}
		HON = {
			if = {
				limit = {
					country_exists = HON
				}
				delete_unit = {
				}
			}
		}
	}
	if = {
		limit = {
			country_exists = BRA
		}
		BRA = {
			if = {
				limit = {
					country_exists = BRA
				}
				delete_unit = {
				}
			}
		}
	}
}

########### MISCELLANEOUS SCRIPTED EFFECTS ###########
nkmp_enable_session_stats_scripted_effect = {
	set_variable = {
		var = nkmp_var_enable_session_stats
		value = 1
	}
}

nkmp_disable_session_stats_scripted_effect = {
	clear_variable = nkmp_var_enable_session_stats
}

nkmp_enable_country_stats_scripted_effect = {
	set_variable = {
		var = nkmp_var_enable_country_stats
		value = 1
	}
}

nkmp_disable_country_stats_scripted_effect = {
	clear_variable = nkmp_var_enable_country_stats
}

nkmp_misc_claim_every_state_scripted_effect = {
	every_state = {
		add_claim_by = ROOT
	}
}

nkmp_misc_core_every_state_scripted_effect = {
	every_state = {
		add_core_of = ROOT
	}
}

nkmp_enable_declare_war_visibility_scripted_effect = {
	set_variable = {
		var = nkmp_var_enable_regions
		value = 1
	}
	set_country_flag = nkmp_flg_regions_war
}

nkmp_disable_declare_war_visibility_scripted_effect = {
	clear_variable = nkmp_var_enable_regions
	clr_country_flag = nkmp_flg_regions_war
}

nkmp_enable_force_declare_war_visibility_scripted_effect = {
	set_variable = {
		var = nkmp_var_enable_regions
		value = 1
	}
	set_country_flag = nkmp_flg_regions_force_war
	set_country_flag = nkmp_flg_regions_select_country
}

nkmp_disable_force_declare_war_visibility_scripted_effect = {
	hidden_effect = {
		clear_variable = nkmp_var_enable_regions
		clr_country_flag = nkmp_flg_regions_force_war
		clr_country_flag = nkmp_flg_regions_select_country_2
		clr_country_flag = nkmp_flg_regions_select_country
		every_country = {
			if = {
				limit = {
					has_country_flag = nkmp_flg_regions_selected_country
				}
				clr_country_flag = nkmp_flg_regions_selected_country
			}
		}
		clear_variable = nkmp_var_regions_set_temp_country_select
	}
}

nkmp_enable_annex_visibility_scripted_effect = {
	set_variable = {
		var = nkmp_var_enable_regions
		value = 1
	}
	set_country_flag = nkmp_flg_regions_annex
}

nkmp_disable_annex_visibility_scripted_effect = {
	clear_variable = nkmp_var_enable_regions
	clr_country_flag = nkmp_flg_regions_annex
}

nkmp_enable_force_puppet_visibility_scripted_effect = {
	set_variable = {
		var = nkmp_var_enable_regions
		value = 1
	}
	set_country_flag = nkmp_flg_regions_puppet
}

nkmp_disable_force_puppet_visibility_scripted_effect = {
	clear_variable = nkmp_var_enable_regions
	clr_country_flag = nkmp_flg_regions_puppet
}

nkmp_enable_change_country_ideology_visibility_scripted_effect = {
	set_variable = {
		var = nkmp_var_enable_regions
		value = 1
	}
	set_country_flag = nkmp_flg_regions_ideology
}

nkmp_disable_change_country_ideology_visibility_scripted_effect = {
	clear_variable = nkmp_var_enable_regions
	clr_country_flag = nkmp_flg_regions_ideology
}

nkmp_enable_change_country_visibility_scripted_effect = {
	set_variable = {
		var = nkmp_var_enable_regions
		value = 1
	}
	set_country_flag = nkmp_flg_regions_change_tag
}

nkmp_disable_change_country_visibility_scripted_effect = {
	clear_variable = nkmp_var_enable_regions
	clr_country_flag = nkmp_flg_regions_change_tag
}

nkmp_show_nuke_visibility_scripted_effect = {
	set_variable = {
		var = nkmp_var_enable_nukes
		value = 1
	}
}

nkmp_hide_nuke_visibility_scripted_effect = {
	clear_variable = nkmp_var_enable_nukes
}

nkmp_show_thermo_nuke_visibility_scripted_effect = {
	set_variable = {
		var = nkmp_var_enable_thermo_nukes
		value = 1
	}
}

nkmp_hide_thermo_nuke_visibility_scripted_effect = {
	clear_variable = nkmp_var_enable_thermo_nukes
}

nkmp_declare_war_on_everyone_scripted_effect = {
	every_other_country = {
		limit = {
			is_faction_leader = yes
		}
		dismantle_faction = yes
	}
	every_other_country = {
		limit = {
			is_in_faction_with = ROOT
		}
		leave_faction = yes
	}
	every_other_country = {
		limit = {
			NOT = {
				is_subject_of = ROOT
			}
		}
		ROOT = {
			declare_war_on = {
				target = PREV
				type = annex_everything
			}
		}
	}
}

nkmp_annex_every_nation_scripted_effect = {
	hidden_effect = {
		every_other_country = {
			THIS = {
				set_country_flag = puppet_army_integrated
			}
			THIS = {
				every_unit_leader = {
					set_nationality = ROOT
				}
				THIS = {
					transfer_navy = {
						target = ROOT
					}
				}
			}
			ROOT = {
				annex_country = {
					target = PREV
					transfer_troops = yes
				}
				every_state = {
					limit = {
						is_core_of = PREV
					}
					add_core_of = ROOT
				}
			}
		}
	}
	custom_effect_tooltip = nkmp_annex_every_nation_TT
}

nkmp_nuke_every_state_scripted_effect = {
	hidden_effect = {
		every_state = {
			THIS = {
				owner = {
					launch_nuke = {
						state = PREV
						use_nuke = no
						nuke_type = nuclear_bomb
					}
				}
			}
		}
	}
	custom_effect_tooltip = nkmp_nuke_every_state_TT
}

nkmp_nuke_state_scripted_effect = {
	launch_nuke = {
		state = FROM
		use_nuke = no
		nuke_type = nuclear_bomb
	}
}

nkmp_thermo_nuke_every_state_scripted_effect = {
	hidden_effect = {
		every_state = {
			THIS = {
				owner = {
					launch_nuke = {
						state = PREV
						use_nuke = no
						nuke_type = thermonuclear_bomb
					}
				}
			}
		}
	}
	custom_effect_tooltip = nkmp_nuke_every_state_TT
}

nkmp_thermo_nuke_state_scripted_effect = {
	launch_nuke = {
		state = FROM
		use_nuke = no
		nuke_type = thermonuclear_bomb
	}
}

########### REGIONAL NATIONS SCRIPTED EFFECTS ###########
nkmp_regional_nation_1_scripted_effect = {
	nkmp_regions_scripted_effect = yes
}

nkmp_regional_nation_2_scripted_effect = {
	nkmp_regions_scripted_effect = yes
}

nkmp_regional_nation_3_scripted_effect = {
	nkmp_regions_scripted_effect = yes
}

nkmp_regional_nation_4_scripted_effect = {
	nkmp_regions_scripted_effect = yes
}

nkmp_regional_nation_5_scripted_effect = {
	nkmp_regions_scripted_effect = yes
}

nkmp_regional_nation_6_scripted_effect = {
	nkmp_regions_scripted_effect = yes
}

nkmp_regional_nation_7_scripted_effect = {
	nkmp_regions_scripted_effect = yes
}