########### Startup Effects ###########
nkmp_panel_startup_scripted_effect = {
	clr_country_flag = nkmp_flg_open_startup_gui
	# AI
	if = {
		limit = {
			ROOT = {
				has_country_flag = nkmp_flg_enable_puppet_ai
			}
		}
		add_ideas = nkmp_puppet_ai_enabled
	}
	# Factions
	if = {
		limit = {
			has_country_flag = nkmp_flg_remove_factions
		}
		every_country = {
			limit = {
				is_faction_leader = yes
			}
			dismantle_faction = yes
		}
	}
	# Guarantees
	if = {
		limit = {
			has_country_flag = nkmp_flg_remove_guarantees
		}
		every_country = {
			THIS = {
				every_other_country = {
					diplomatic_relation = {
						country = PREV
						relation = guarantee
						active = no
					}
				}
			}
		}
	}
	# Vassals
	if = {
		limit = {
			has_country_flag = nkmp_flg_remove_vassals
		}
		every_country = {
			limit = {
				is_subject = yes
			}
			OVERLORD = {
				set_autonomy = {
					target = PREV
					autonomy_state = autonomy_free
				}
			}
		}
	}
	# Stop All Wars
	if = {
		limit = {
			has_country_flag = nkmp_flg_stop_all_wars
		}
		every_country = {
			limit = {
				has_war = yes
			}
			THIS = {
				every_other_country = {
					limit = {
						has_war_with = PREV
					}
					white_peace = PREV
				}
			}
		}
	}
	# Global Max Infrastructure
	if = {
		limit = {
			has_country_flag = nkmp_flg_global_infrastructure
		}
		every_state = {
			add_building_construction = {
				type = infrastructure
				level = 10
				instant_build = yes
			}
			add_extra_state_shared_building_slots = 1000
		}
		every_state = {
			limit = {
				OR = {
					has_railway_level = {
						level = 1
						state = THIS
					}
					has_railway_level = {
						level = 2
						state = THIS
					}
					has_railway_level = {
						level = 3
						state = THIS
					}
					has_railway_level = {
						level = 4
						state = THIS
					}
					has_railway_level = {
						level = 5
						state = THIS
					}
					has_railway_level = {
						level = 6
						state = THIS
					}
				}
			}
			set_temp_variable = {
				nkmp_temp_railroad_upgrade_var = THIS
			}
			if = {
				limit = {
					has_global_flag = nkmp_flg_global_MD_Mode
				}
				THIS = {
					build_railway = {
						level = 6
						fallback = yes
						start_state = nkmp_temp_railroad_upgrade_var
						target_state = THIS
					}
				}
			}
			else = {
				THIS = {
					build_railway = {
						level = 5
						fallback = yes
						start_state = nkmp_temp_railroad_upgrade_var
						target_state = THIS
					}
				}
			}
		}
	}
	# Remove DMZ
	if = {
		limit = {
			has_country_flag = nkmp_flg_remove_dmz
		}
		every_state = {
			limit = {
				is_demilitarized_zone = yes
			}
			set_demilitarized_zone = no
		}
	}
	# Forbid Volunteers
	if = {
		limit = {
			has_country_flag = nkmp_flg_forbid_volunteers
		}
		every_country = {
			limit = {
				is_ai = yes
			}
			set_rule = {
				can_send_volunteers = no
			}
			add_ideas = nkmp_forbid_volunteers_idea
		}
	}
	# Forbid Lend Lease
	if = {
		limit = {
			has_country_flag = nkmp_flg_forbid_lend_lease
		}
		every_country = {
			limit = {
				is_ai = yes
			}
			add_ideas = nkmp_forbid_lend_lease_idea
		}
	}
	# Forbid Guarantees
	if = {
		limit = {
			has_country_flag = nkmp_flg_forbid_guarantees
		}
		every_country = {
			limit = {
				is_ai = yes
			}
			add_ideas = nkmp_forbid_guarantees_idea
		}
	}
	# Core All
	if = {
		limit = {
			has_country_flag = nkmp_flg_core_all
		}
		every_state = {
			add_core_of = ROOT
		}
	}
	# Turn Off Energy
	if = {
		limit = {
			has_country_flag = nkmp_flg_energy_disabled
			NOT = {
				has_global_flag = nkmp_flg_global_MD_Mode
			}
		}
		nkmp_energy_disabled_scripted_effect = yes
	}
	else_if = {
		limit = {
			has_country_flag = nkmp_flg_energy_disabled
			has_global_flag = nkmp_flg_global_MD_Mode
		}
		nkmp_md_energy_disabled_scripted_effect = yes
	}
	# Turn Off Global Energy
	if = {
		limit = {
			has_country_flag = nkmp_flg_global_energy_disabled
			NOT = {
				has_global_flag = nkmp_flg_global_MD_Mode
			}
		}
		every_country = {
			nkmp_energy_disabled_scripted_effect = yes
		}
	}
	else_if = {
		limit = {
			has_country_flag = nkmp_flg_global_energy_disabled
			has_global_flag = nkmp_flg_global_MD_Mode
		}
		every_country = {
			nkmp_md_energy_disabled_scripted_effect = yes
		}
	}
}

########### Panel Effects ###########
nkmp_panel_close_scripted_effect = {
	clr_country_flag = nkmp_flg_open_modpack_panel_gui
	clr_country_flag = nkmp_flg_open_startup_gui
	clr_country_flag = nkmp_flg_open_main_menu_selection_about_gui
	clr_country_flag = nkmp_flg_open_main_menu_selection_settings_gui
	clr_country_flag = nkmp_flg_open_main_menu_selection_gui
	clr_country_flag = nkmp_flg_open_active_mods_gui
	clr_country_flag = nkmp_flg_active_mods_vanilla
	clr_country_flag = nkmp_flg_active_mods_md
}
