############## вече ага
#вплюс
zmn_small_support_vrat = {	#минимум
	custom_effect_tooltip = small_support_vrat_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = 2 }
	add_to_variable = { vrata_support = temp_factor }
	round_variable = vrata_support
	clamp_variable = { var = vrata_support max = vrata_total min = 0 }
	zmn_recalc_vrata_icon_frames = yes
	zmn_recal_for_nationspirit = yes
}
zmn_small_support_vrat_2 = {	#2 процента
	custom_effect_tooltip = small_support_vrat_2_tt	
	add_to_variable = { vrata_support = 2 }
	round_variable = vrata_support
	clamp_variable = { var = vrata_support max = vrata_total min = 0 }
	zmn_recalc_vrata_icon_frames = yes
	zmn_recal_for_nationspirit = yes
}
zmn_support_vrat_3 = {	#3 процента
	custom_effect_tooltip = support_vrat_3_tt	
	add_to_variable = { vrata_support = 3 }
	round_variable = vrata_support
	clamp_variable = { var = vrata_support max = vrata_total min = 0 }
	zmn_recalc_vrata_icon_frames = yes
	zmn_recal_for_nationspirit = yes
}
#########
zmn_small_debaff_vrat_1 = {	#1 процента минус
	custom_effect_tooltip = small_debaff_vrat_1_tt	
	subtract_from_variable = { vrata_support = 1 }
	round_variable = vrata_support
	clamp_variable = { var = vrata_support max = vrata_total min = 0 }
	zmn_recalc_vrata_icon_frames = yes
	zmn_recal_for_nationspirit = yes
}
zmn_debaff_vrat_2 = {	#2 процента минус
	custom_effect_tooltip = debaff_vrat_2_tt	
	subtract_from_variable = { vrata_support = 2 }
	round_variable = vrata_support
	clamp_variable = { var = vrata_support max = vrata_total min = 0 }
	zmn_recalc_vrata_icon_frames = yes
	zmn_recal_for_nationspirit = yes
}
zmn_debaff_vrat_3 = {	#3 процента минус
	custom_effect_tooltip = debaff_vrat_3_tt	
	subtract_from_variable = { vrata_support = 3 }
	round_variable = vrata_support
	clamp_variable = { var = vrata_support max = vrata_total min = 0 }
	zmn_recalc_vrata_icon_frames = yes
	zmn_recal_for_nationspirit = yes
}
zmn_debaff_vrat_4 = {	#4 процента минус
	custom_effect_tooltip = debaff_vrat_4_tt	
	subtract_from_variable = { vrata_support = 4 }
	round_variable = vrata_support
	clamp_variable = { var = vrata_support max = vrata_total min = 0 }
	zmn_recalc_vrata_icon_frames = yes
	zmn_recal_for_nationspirit = yes
}
zmn_debaff_vrat_6 = {	#6 процента минус
	custom_effect_tooltip = debaff_vrat_6_tt	
	subtract_from_variable = { vrata_support = 6 }
	round_variable = vrata_support
	clamp_variable = { var = vrata_support max = vrata_total min = 0 }
	zmn_recalc_vrata_icon_frames = yes
	zmn_recal_for_nationspirit = yes
}
##########
zmn_test_plus = {
	custom_effect_tooltip = small_support_vrat_tt	
	add_to_variable = { vrata_support = 1 }
	round_variable = vrata_support
	clamp_variable = { var = vrata_support max = vrata_total min = 0 }
	zmn_recalc_vrata_icon_frames = yes
	zmn_recal_for_nationspirit = yes
}
zmn_test_plus_10 = {
	custom_effect_tooltip = small_support_vrat_tt	
	add_to_variable = { vrata_support = 10 }
	round_variable = vrata_support
	clamp_variable = { var = vrata_support max = vrata_total min = 0 }
	zmn_recalc_vrata_icon_frames = yes
	zmn_recal_for_nationspirit = yes
}
zmn_test_minus = {
	custom_effect_tooltip = small_support_vrat_tt	
	subtract_from_variable = { vrata_support = 1 }
	round_variable = vrata_support
	clamp_variable = { var = vrata_support max = vrata_total min = 0 }
	zmn_recalc_vrata_icon_frames = yes
	zmn_recal_for_nationspirit = yes
}
zmn_test_minus_10 = {
	custom_effect_tooltip = small_support_vrat_tt	
	subtract_from_variable = { vrata_support = 10 }
	round_variable = vrata_support
	clamp_variable = { var = vrata_support max = vrata_total min = 0 }
	zmn_recalc_vrata_icon_frames = yes
	zmn_recal_for_nationspirit = yes
}



#рекалл шкалы
zmn_recalc_vrata_icon_frames = {	
	set_temp_variable = { vratatp_temp = vrata_support }
	divide_temp_variable = { vratatp_temp = vrata_total }
	multiply_temp_variable = { vratatp_temp = 21 }
	if = {
		limit = { check_variable = { vratatp_temp > 0 } }
		clamp_temp_variable = {
			var = vratatp_temp
			min = 1
			max = 21
		}
	}
	else = {
		set_temp_variable = { vratatp_temp = 1 }
	}
	set_variable = { current_vrata_icon_frame = vratatp_temp }	
}

##################################################
# проброс на корректность нацидеи
zmn_recal_for_nationspirit = {	
	if = {
		limit = {
			check_variable = {
				vrata_support < 20
			}
		}
		zmn_rvenie_0_sett = yes
	}
	if = {
		limit = {
			check_variable = {
				vrata_support > 19
			}
			check_variable = {
				vrata_support < 40
			}
		}
		zmn_rvenie_1_sett = yes
	}
	if = {
		limit = {
			check_variable = {
				vrata_support > 39
			}
			check_variable = {
				vrata_support < 60
			}
		}
		zmn_rvenie_2_sett = yes
	}
	if = {
		limit = {
			check_variable = {
				vrata_support > 59
			}
			check_variable = {
				vrata_support < 80
			}
		}
		zmn_rvenie_3_sett = yes
	}
	if = {
		limit = {
			check_variable = {
				vrata_support > 79
			}			
		}
		zmn_rvenie_4_sett = yes
	}
}
#######################################################
zmn_rvenie_0_sett = {	#сброс идей
	if = {
		limit = {
			has_idea = zmn_rvenie_1
		}
		remove_ideas = zmn_rvenie_1
	}
	if = {
		limit = {
			has_idea = zmn_rvenie_2
		}
		remove_ideas = zmn_rvenie_2
	}
	if = {
		limit = {
			has_idea = zmn_rvenie_3
		}
		remove_ideas = zmn_rvenie_3
	}
	if = {
		limit = {
			has_idea = zmn_rvenie_4
		}
		remove_ideas = zmn_rvenie_4
	}
}
zmn_rvenie_1_sett = {	#установка рвения 1
	if = {
		limit = {
			NOT = {
				has_idea = zmn_rvenie_1
			}	
		}
		add_ideas = zmn_rvenie_1
	}
	if = {
		limit = {
			has_idea = zmn_rvenie_2
		}
		remove_ideas = zmn_rvenie_2
	}
	if = {
		limit = {
			has_idea = zmn_rvenie_3
		}
		remove_ideas = zmn_rvenie_3
	}
	if = {
		limit = {
			has_idea = zmn_rvenie_4
		}
		remove_ideas = zmn_rvenie_4
	}
}
zmn_rvenie_2_sett = {	#установка рвения 2
	if = {
		limit = {			
			has_idea = zmn_rvenie_1				
		}
		remove_ideas = zmn_rvenie_1
	}
	if = {
		limit = {
			NOT = {
				has_idea = zmn_rvenie_2
			}
		}
		add_ideas = zmn_rvenie_2
	}
	if = {
		limit = {
			has_idea = zmn_rvenie_3
		}
		remove_ideas = zmn_rvenie_3
	}
	if = {
		limit = {
			has_idea = zmn_rvenie_4
		}
		remove_ideas = zmn_rvenie_4
	}
}
zmn_rvenie_3_sett = {	#установка рвения 3
	if = {
		limit = {			
			has_idea = zmn_rvenie_1				
		}
		remove_ideas = zmn_rvenie_1
	}
	if = {
		limit = {			
			has_idea = zmn_rvenie_2			
		}
		remove_ideas = zmn_rvenie_2
	}
	if = {
		limit = {
			NOT = {
				has_idea = zmn_rvenie_3
			}
		}
		add_ideas = zmn_rvenie_3
	}
	if = {
		limit = {
			has_idea = zmn_rvenie_4
		}
		remove_ideas = zmn_rvenie_4
	}
}
zmn_rvenie_4_sett = {		#установка рвения 4
	if = {
		limit = {			
			has_idea = zmn_rvenie_1				
		}
		remove_ideas = zmn_rvenie_1
	}
	if = {
		limit = {			
			has_idea = zmn_rvenie_2			
		}
		remove_ideas = zmn_rvenie_2
	}
	if = {
		limit = {			
			has_idea = zmn_rvenie_3			
		}
		remove_ideas = zmn_rvenie_3
	}
	if = {
		limit = {
			NOT = {
				has_idea = zmn_rvenie_4
			}
		}
		add_ideas = zmn_rvenie_4
	}
}
zmn_vashe_chungo_razvalilos = {		# гуд бай чунго
	delete_unit_template_and_units = {
		division_template = "Bubing Shi"
	}
	delete_unit_template_and_units = {
		division_template = "Zhimindi Shi"
	}
	delete_unit_template_and_units = {
		division_template = "Qibing Jun"
	}
	delete_unit_template_and_units = {
		division_template = "Zhuangjia Shi"
	}
	delete_unit_template_and_units = {
		division_template = "Jidong Shi"
	}
	delete_unit_template_and_units = {
		division_template = "Shandi Shi"
	}
	delete_unit_template_and_units = {
		division_template = "Zhimindi Lu"
	}
	if = {
		limit = {
			is_faction_leader = yes
		}
		dismantle_faction = yes
	}
	every_other_country = {
		limit = { 
			is_subject_of = ZMN
			NOT = {
				tag = ZHK
			}
		}
		ZMN = { set_autonomy = { target = PREV autonomy_state = autonomy_free } }
		drop_cosmetic_tag = yes	##	
	}	
	if = {
		limit = {
			ZHK = {
				is_subject_of = ZMN
			}
		}
		ZMN = { set_autonomy = { target = ZHK autonomy_state = autonomy_free } }
	}
	release = XMI
	release = ZYU
	release = XCH
	release = ZXS	
	ZMN_mao_dong = { set_nationality = XMI }
	ZMN_luo_jiahao = { set_nationality = XCH }	# XCH Чу
	ZMN_bao_duan = { set_nationality = ZYU }	# ZYU ЮЭ
	ZMN_xian_zhou = { set_nationality = ZXS }	# ZXS Шу
	# XMI = {
		# create_country_leader = {	
			# name = "Mao Dong"
			# desc = ""
			# picture = "zmi_Mao_ddong.tga"
			# expire = "2010.1.1"
			# ideology = parlament_monarch
			# traits = {		
			# }
		# }
	# }
	# ZYU = {
		# create_country_leader = {	
			# name = "Bao Duan"
			# desc = ""
			# picture = "ZYU_Bao_duan.tga"
			# expire = "2010.1.1"
			# ideology = parlament_monarch
			# traits = {		
			# }
		# }
	# }
	# XCH = {
		# create_country_leader = {	
			# name = "Luo Jiahao"
			# desc = ""
			# picture = "XCH_Luo_jiahao.tga"
			# expire = "2010.1.1"
			# ideology = parlament_monarch
			# traits = {		
			# }
		# }
	# }
	# ZXS = {
		# create_country_leader = {	
			# name = "Xian Zhou"
			# desc = ""
			# picture = "ZXS_Xian_zzhou.tga"
			# expire = "2010.1.1"
			# ideology = parlament_monarch
			# traits = {		
			# }
		# }
	# }
	if = {
		limit = {
			NOT = {
				country_exists = ZTO
			}
		}
		release = ZTO
	}
	else_if = {
		limit = {
			country_exists = ZTO
			controls_state = 623 
		}
		ZTO = {
			transfer_state = 623
		}
	}
			else_if = {
				limit = {
					country_exists = ZTO
					controls_state = 978 
				}
				ZTO = {
					transfer_state = 978
				}
			}
			else_if = {
				limit = {
					country_exists = ZTO
					controls_state = 327 
				}
				ZTO = {
					transfer_state = 327
				}
			}
			else_if = {
				limit = {
					country_exists = ZTO
					controls_state = 624 
				}
				ZTO = {
					transfer_state = 624
				}
			}
			
			if = {
				limit = {
					NOT = {
						country_exists = ZCH
					}
				}
				release = ZCH								
			}
			else_if = {
				limit = {
					country_exists = ZCH
					controls_state = 672 
				}
				ZCH = {
					transfer_state = 672
				}
			}
			else_if = {
				limit = {
					country_exists = ZCH
					controls_state = 921 
				}
				ZCH = {
					transfer_state = 921
				}
			}
			else_if = {
				limit = {
					country_exists = ZCH
					controls_state = 920 
				}
				ZCH = {
					transfer_state = 920
				}
			}
			else_if = {
				limit = {
					country_exists = ZCH
					controls_state = 918 
				}
				ZCH = {
					transfer_state = 918
				}
			}
			if = {
				limit = {
					NOT = {
						country_exists = ZPH
					}
				}
				release = ZPH
			}
			if = {
				limit = {
					controls_state = 815				
				}
				ZSM = {
					transfer_state = 815					
					country_event = { days = 1 id = jungo.21 }
				}
			}
			if = {
				limit = {
					controls_state = 808				
				}
				ZCC = {
					transfer_state = 808					
					country_event = { days = 1 id = jungo.22 }
				}
			}
			if = {
				limit = {
					controls_state = 813				
				}
				ZGK = {
					transfer_state = 813					
				}
			}
			
			if = {
				limit = {
					NOT = {
						country_exists = ZUS
					}
				}
				release = ZUS				
				ZUS = {
					country_event = { days = 4 id = jungo.27 }
					load_oob = "ZUS_raspad"
				}
			}
			else_if = {
				limit = {
					country_exists = ZUS
					controls_state = 923 
				}
				ZUS = {
					transfer_state = 923
				}
			}
			else_if = {
				limit = {
					country_exists = ZUS
					controls_state = 924 
				}
				ZUS = {
					transfer_state = 924
				}
			}
			else_if = {
				limit = {
					country_exists = ZUS
					controls_state = 673 
				}
				ZUS = {
					transfer_state = 673
				}
			}
			
			if = {
				limit = {
					controls_state = 919				
				}
				ZBS = {
					transfer_state = 919
					country_event = { days = 1 id = jungo.25 }
				}
			}
			
			if = {
				limit = {
					controls_state = 930				
				}
				ZVJ = {
					transfer_state = 930
					country_event = { days = 1 id = jungo.26 }
				}
			}
			
			if = {
				limit = {
					controls_state = 979				
				}
				ZCY = {
					transfer_state = 979
					## event
				}
			}
			
			if = {
				limit = {
					NOT = {
						country_exists = ZPT
					}
				}
				release = ZPT
				ZPT = {
					load_oob = "ZPT_raspad"
				}
			}
			else_if = {
				limit = {
					country_exists = ZPT
					controls_state = 512 
				}
				ZPT = {
					transfer_state = 512
				}
			}
			else_if = {
				limit = {
					country_exists = ZPT
					controls_state = 1133 
				}
				ZPT = {
					transfer_state = 1133
				}
			}
			else_if = {
				limit = {
					country_exists = ZPT
					controls_state = 507 
				}
				ZPT = {
					transfer_state = 507
				}
			}
			
			if = {
				limit = {
					NOT = {
						country_exists = ZMZ
					}
				}
				release = ZMZ
				ZMZ = {
					load_oob = "ZMZ_raspad"
					country_event = { days = 15 id = jungo.28 }
				}
			}
			else_if = {
				limit = {
					country_exists = ZMZ
					controls_state = 279 
				}
				ZMZ = {
					transfer_state = 279
				}
			}
			else_if = {
				limit = {
					country_exists = ZMZ
					controls_state = 508 
				}
				ZMZ = {
					transfer_state = 508
				}
			}
			else_if = {
				limit = {
					country_exists = ZMZ
					controls_state = 506 
				}
				ZMZ = {
					transfer_state = 506
				}
			}
			else_if = {
				limit = {
					country_exists = ZMZ
					controls_state = 1134 
				}
				ZMZ = {
					transfer_state = 1134
				}
			}
			
			if = {
				limit = {
					controls_state = 1159				
				}
				ZCM = {
					transfer_state = 1159
					## event
				}
			}
			if = {
				limit = {
					controls_state = 305				
				}
				ZCM = {
					transfer_state = 305
					## event
				}
			}
			if = {
				limit = {
					controls_state = 1141				
				}
				ZCM = {
					transfer_state = 1141
					## event
				}
			}
			
			if = {
				limit = {
					controls_state = 317				
				}
				ZMP = {
					transfer_state = 317
					## event
				}
			}
			if = {
				limit = {
					controls_state = 316				
				}
				ZMP = {
					transfer_state = 316
					## event
				}
			}
			if = {
				limit = {
					controls_state = 312				
				}
				ZMP = {
					transfer_state = 312
					## event
				}
			}
			
			if = {
				limit = {
					controls_state = 377
					country_exists = ZTH	
				}
				ZTH = {
					transfer_state = 377
					country_event = { id = sinka.1 }
				}
			}
			if = {
				limit = {
					controls_state = 377
					NOT = {
						country_exists = ZTH	
					}	
				}
				XVP = {
					transfer_state = 377
					## event
				}
			}
			
			if = {
				limit = {
					controls_state = 822
					country_exists = ZTH	
				}
				ZTH = {
					transfer_state = 822
					## event
				}
			}
			if = {
				limit = {
					controls_state = 822
					NOT = {
						country_exists = ZTH	
					}	
				}
				ZPC = {
					transfer_state = 822
					## event
				}
			}
			
			if = {
				limit = {
					controls_state = 823
					country_exists = ZTH	
				}
				ZTH = {
					transfer_state = 823
					## event
				}
			}
			if = {
				limit = {
					controls_state = 823
					NOT = {
						country_exists = ZTH	
					}	
				}
				ZNV = {
					transfer_state = 823
					## event
				}
			}
			if = {
				limit = {
					controls_state = 376
					country_exists = ZTH	
				}
				ZTH = {
					transfer_state = 376
					## event
				}
			}
			if = {
				limit = {
					controls_state = 376
					NOT = {
						country_exists = ZTH	
					}	
				}
				ZNV = {
					transfer_state = 376
					## event
				}
			}
			
			if = {
				limit = {
					controls_state = 483
					country_exists = ZTH	
				}
				ZTH = {
					transfer_state = 483
					## event
				}
			}
			if = {
				limit = {
					controls_state = 483
					NOT = {
						country_exists = ZTH	
					}	
				}
				ZHK = {
					transfer_state = 483
					## event
				}
			}
			
			if = {
				limit = {
					controls_state = 482
					country_exists = ZTH	
				}
				ZTH = {
					transfer_state = 482
					## event
				}
			}
			if = {
				limit = {
					controls_state = 482
					NOT = {
						country_exists = ZTH	
					}	
				}
				ZHK = {
					transfer_state = 482
					## event
				}
			}
	every_other_country = {
		limit = {
			NOT = {	
				has_government = communism
			}	
		}
		country_event = { days = 5 id = jungo.231 }
	}
		
}

zmn_kolonii_chungo_otpali = {	# только колонии отпали, без ванст
	every_other_country = {
		limit = { 
			is_subject_of = ZMN
			NOT = {
				tag = ZHK
			}
		}
		ZMN = { set_autonomy = { target = PREV autonomy_state = autonomy_free } }
		drop_cosmetic_tag = yes	##	
	}	
	if = {
		limit = {
			ZHK = {
				is_subject_of = ZMN
			}
		}
		ZMN = { set_autonomy = { target = ZHK autonomy_state = autonomy_free } }
	}						
	if = {
		limit = {
			NOT = {
				country_exists = ZTO
			}
		}
		release = ZTO
	}
	else_if = {
		limit = {
			country_exists = ZTO
			controls_state = 623 
		}
		ZTO = {
			transfer_state = 623
		}
	}
	else_if = {
		limit = {
			country_exists = ZTO
			controls_state = 978 
		}
		ZTO = {
			transfer_state = 978
		}
	}
	else_if = {
		limit = {
			country_exists = ZTO
			controls_state = 327 
		}
		ZTO = {
			transfer_state = 327
		}
	}
			else_if = {
				limit = {
					country_exists = ZTO
					controls_state = 624 
				}
				ZTO = {
					transfer_state = 624
				}
			}
			
			if = {
				limit = {
					NOT = {
						country_exists = ZCH
					}
				}
				release = ZCH								
			}
			else_if = {
				limit = {
					country_exists = ZCH
					controls_state = 672 
				}
				ZCH = {
					transfer_state = 672
				}
			}
			else_if = {
				limit = {
					country_exists = ZCH
					controls_state = 921 
				}
				ZCH = {
					transfer_state = 921
				}
			}
			else_if = {
				limit = {
					country_exists = ZCH
					controls_state = 920 
				}
				ZCH = {
					transfer_state = 920
				}
			}
			else_if = {
				limit = {
					country_exists = ZCH
					controls_state = 918 
				}
				ZCH = {
					transfer_state = 918
				}
			}
			if = {
				limit = {
					NOT = {
						country_exists = ZPH
					}
				}
				release = ZPH
			}
			if = {
				limit = {
					controls_state = 815				
				}
				ZSM = {
					transfer_state = 815					
					country_event = { days = 1 id = jungo.21 }
				}
			}
			if = {
				limit = {
					controls_state = 808				
				}
				ZCC = {
					transfer_state = 808					
					country_event = { days = 1 id = jungo.22 }
				}
			}
			if = {
				limit = {
					controls_state = 813				
				}
				ZGK = {
					transfer_state = 813					
				}
			}
			
			if = {
				limit = {
					NOT = {
						country_exists = ZUS
					}
				}
				release = ZUS				
				ZUS = {
					country_event = { days = 4 id = jungo.27 }
					load_oob = "ZUS_raspad"
				}
			}
			else_if = {
				limit = {
					country_exists = ZUS
					controls_state = 923 
				}
				ZUS = {
					transfer_state = 923
				}
			}
			else_if = {
				limit = {
					country_exists = ZUS
					controls_state = 924 
				}
				ZUS = {
					transfer_state = 924
				}
			}
			else_if = {
				limit = {
					country_exists = ZUS
					controls_state = 673 
				}
				ZUS = {
					transfer_state = 673
				}
			}
			
			if = {
				limit = {
					controls_state = 919				
				}
				ZBS = {
					transfer_state = 919
					country_event = { days = 1 id = jungo.25 }
				}
			}
			
			if = {
				limit = {
					controls_state = 930				
				}
				ZVJ = {
					transfer_state = 930
					country_event = { days = 1 id = jungo.26 }
				}
			}
			
			if = {
				limit = {
					controls_state = 979				
				}
				ZCY = {
					transfer_state = 979
					## event
				}
			}
			
			if = {
				limit = {
					NOT = {
						country_exists = ZPT
					}
				}
				release = ZPT
				ZPT = {
					load_oob = "ZPT_raspad"
				}
			}
			else_if = {
				limit = {
					country_exists = ZPT
					controls_state = 512 
				}
				ZPT = {
					transfer_state = 512
				}
			}
			else_if = {
				limit = {
					country_exists = ZPT
					controls_state = 1133 
				}
				ZPT = {
					transfer_state = 1133
				}
			}
			else_if = {
				limit = {
					country_exists = ZPT
					controls_state = 507 
				}
				ZPT = {
					transfer_state = 507
				}
			}
			
			if = {
				limit = {
					NOT = {
						country_exists = ZMZ
					}
				}
				release = ZMZ
				ZMZ = {
					load_oob = "ZMZ_raspad"
					country_event = { days = 15 id = jungo.28 }
				}
			}
			else_if = {
				limit = {
					country_exists = ZMZ
					controls_state = 279 
				}
				ZMZ = {
					transfer_state = 279
				}
			}
			else_if = {
				limit = {
					country_exists = ZMZ
					controls_state = 508 
				}
				ZMZ = {
					transfer_state = 508
				}
			}
			else_if = {
				limit = {
					country_exists = ZMZ
					controls_state = 506 
				}
				ZMZ = {
					transfer_state = 506
				}
			}
			else_if = {
				limit = {
					country_exists = ZMZ
					controls_state = 1134 
				}
				ZMZ = {
					transfer_state = 1134
				}
			}
			
			if = {
				limit = {
					controls_state = 1159				
				}
				ZCM = {
					transfer_state = 1159
					## event
				}
			}
			if = {
				limit = {
					controls_state = 305				
				}
				ZCM = {
					transfer_state = 305
					## event
				}
			}
			if = {
				limit = {
					controls_state = 1141				
				}
				ZCM = {
					transfer_state = 1141
					## event
				}
			}
			
			if = {
				limit = {
					controls_state = 317				
				}
				ZMP = {
					transfer_state = 317
					## event
				}
			}
			if = {
				limit = {
					controls_state = 316				
				}
				ZMP = {
					transfer_state = 316
					## event
				}
			}
			if = {
				limit = {
					controls_state = 312				
				}
				ZMP = {
					transfer_state = 312
					## event
				}
			}
			
			if = {
				limit = {
					controls_state = 377
					country_exists = ZTH	
				}
				ZTH = {
					transfer_state = 377
					country_event = { id = sinka.1 }
				}
			}
			if = {
				limit = {
					controls_state = 377
					NOT = {
						country_exists = ZTH	
					}	
				}
				XVP = {
					transfer_state = 377
					## event
				}
			}
			
			if = {
				limit = {
					controls_state = 822
					country_exists = ZTH	
				}
				ZTH = {
					transfer_state = 822
					## event
				}
			}
			if = {
				limit = {
					controls_state = 822
					NOT = {
						country_exists = ZTH	
					}	
				}
				ZPC = {
					transfer_state = 822
					## event
				}
			}
			
			if = {
				limit = {
					controls_state = 823
					country_exists = ZTH	
				}
				ZTH = {
					transfer_state = 823
					## event
				}
			}
			if = {
				limit = {
					controls_state = 823
					NOT = {
						country_exists = ZTH	
					}	
				}
				ZNV = {
					transfer_state = 823
					## event
				}
			}
			if = {
				limit = {
					controls_state = 376
					country_exists = ZTH	
				}
				ZTH = {
					transfer_state = 376
					## event
				}
			}
			if = {
				limit = {
					controls_state = 376
					NOT = {
						country_exists = ZTH	
					}	
				}
				ZNV = {
					transfer_state = 376
					## event
				}
			}
			
			if = {
				limit = {
					controls_state = 483
					country_exists = ZTH	
				}
				ZTH = {
					transfer_state = 483
					## event
				}
			}
			if = {
				limit = {
					controls_state = 483
					NOT = {
						country_exists = ZTH	
					}	
				}
				ZHK = {
					transfer_state = 483
					## event
				}
			}
			
			if = {
				limit = {
					controls_state = 482
					country_exists = ZTH	
				}
				ZTH = {
					transfer_state = 482
					## event
				}
			}
			if = {
				limit = {
					controls_state = 482
					NOT = {
						country_exists = ZTH	
					}	
				}
				ZHK = {
					transfer_state = 482
					## event
				}
			}
			every_other_country = {
				limit = {
					NOT = {	
						has_government = communism
					}	
				}
				country_event = { days = 5 id = jungo.232 }
			}
		
}

####################################
zmn_loyality_omniki_plus_1 = {	#омникам плюс 3-8
	custom_effect_tooltip = zmn_loyality_omniki_plus_1_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = 8 }
	clamp_temp_variable = { var = temp_factor min = 3 max = 8 }
	add_to_variable = { zmn_loyality_omniki_var = temp_factor }
	round_variable = zmn_loyality_omniki_var
	clamp_variable = { var = zmn_loyality_omniki_var max = 100 min = 0 }	
}
zmn_loyality_omniki_plus_2 = {	#омникам плюс 9-15
	custom_effect_tooltip = zmn_loyality_omniki_plus_2_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = 15 }
	clamp_temp_variable = { var = temp_factor min = 9 max = 15 }
	add_to_variable = { zmn_loyality_omniki_var = temp_factor }
	round_variable = zmn_loyality_omniki_var
	clamp_variable = { var = zmn_loyality_omniki_var max = 100 min = 0 }	
}
zmn_loyality_omniki_plus_3 = {	#омникам плюс 15-23
	custom_effect_tooltip = zmn_loyality_omniki_plus_3_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = 23 }
	clamp_temp_variable = { var = temp_factor min = 15 max = 23 }
	add_to_variable = { zmn_loyality_omniki_var = temp_factor }
	round_variable = zmn_loyality_omniki_var
	clamp_variable = { var = zmn_loyality_omniki_var max = 100 min = 0 }	
}
zmn_loyality_omniki_minus_1 = {	#омникам минус 3-8
	custom_effect_tooltip = zmn_loyality_omniki_minus_1_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = -8 }
	clamp_temp_variable = { var = temp_factor max = -3 min = -8 }
	add_to_variable = { zmn_loyality_omniki_var = temp_factor }
	round_variable = zmn_loyality_omniki_var
	clamp_variable = { var = zmn_loyality_omniki_var max = 100 min = 0 }	
}
zmn_loyality_omniki_minus_2 = {	#омникам минус 9-15
	custom_effect_tooltip = zmn_loyality_omniki_minus_2_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = -15 }
	clamp_temp_variable = { var = temp_factor max = -9 min = -15 }
	add_to_variable = { zmn_loyality_omniki_var = temp_factor }
	round_variable = zmn_loyality_omniki_var
	clamp_variable = { var = zmn_loyality_omniki_var max = 100 min = 0 }	
}
zmn_loyality_omniki_minus_3 = {	#омникам минус 15-23
	custom_effect_tooltip = zmn_loyality_omniki_minus_3_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = -23 }
	clamp_temp_variable = { var = temp_factor max = -15 min = -23 }
	add_to_variable = { zmn_loyality_omniki_var = temp_factor }
	round_variable = zmn_loyality_omniki_var
	clamp_variable = { var = zmn_loyality_omniki_var max = 100 min = 0 }	
}

zmn_loyality_vanstva_plus_1 = {	#ванства плюс 3-8
	custom_effect_tooltip = zmn_loyality_vanstva_plus_1_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = 8 }
	clamp_temp_variable = { var = temp_factor min = 3 max = 8 }
	add_to_variable = { zmn_loyality_vanstva_var = temp_factor }
	round_variable = zmn_loyality_vanstva_var
	clamp_variable = { var = zmn_loyality_vanstva_var max = 100 min = 0 }	
}
zmn_loyality_vanstva_plus_2 = {	#ванства плюс 9-15
	custom_effect_tooltip = zmn_loyality_vanstva_plus_2_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = 15 }
	clamp_temp_variable = { var = temp_factor min = 9 max = 15 }
	add_to_variable = { zmn_loyality_vanstva_var = temp_factor }
	round_variable = zmn_loyality_vanstva_var
	clamp_variable = { var = zmn_loyality_vanstva_var max = 100 min = 0 }	
}
zmn_loyality_vanstva_plus_3 = {	#ванства плюс 15-23
	custom_effect_tooltip = zmn_loyality_vanstva_plus_3_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = 23 }
	clamp_temp_variable = { var = temp_factor min = 15 max = 23 }
	add_to_variable = { zmn_loyality_vanstva_var = temp_factor }
	round_variable = zmn_loyality_vanstva_var
	clamp_variable = { var = zmn_loyality_vanstva_var max = 100 min = 0 }	
}
zmn_loyality_vanstva_minus_1 = {	#ванства минус 3-8
	custom_effect_tooltip = zmn_loyality_vanstva_minus_1_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = -8 }
	clamp_temp_variable = { var = temp_factor max = -3 min = -8 }
	add_to_variable = { zmn_loyality_vanstva_var = temp_factor }
	round_variable = zmn_loyality_vanstva_var
	clamp_variable = { var = zmn_loyality_vanstva_var max = 100 min = 0 }	
}
zmn_loyality_vanstva_minus_2 = {	#ванства минус 9-15
	custom_effect_tooltip = zmn_loyality_vanstva_minus_2_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = -15 }
	clamp_temp_variable = { var = temp_factor max = -9 min = -15 }
	add_to_variable = { zmn_loyality_vanstva_var = temp_factor }
	round_variable = zmn_loyality_vanstva_var
	clamp_variable = { var = zmn_loyality_vanstva_var max = 100 min = 0 }	
}
zmn_loyality_vanstva_minus_3 = {	#ванства минус 15-23
	custom_effect_tooltip = zmn_loyality_vanstva_minus_3_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = -23 }
	clamp_temp_variable = { var = temp_factor max = -15 min = -23 }
	add_to_variable = { zmn_loyality_vanstva_var = temp_factor }
	round_variable = zmn_loyality_vanstva_var
	clamp_variable = { var = zmn_loyality_vanstva_var max = 100 min = 0 }	
}

###############
zmn_zhuhou_support_plus_1 = {	# +2 +5
	custom_effect_tooltip = zmn_zhuhou_support_plus_1_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = 5 }
	clamp_temp_variable = { var = temp_factor min = 2 max = 5 }
	add_to_variable = { zmn_zhuhou_support = temp_factor }
	round_variable = zmn_zhuhou_support
	clamp_variable = { var = zmn_zhuhou_support max = 100 min = 0 }
	zmn_recalc_zhuhou_icon_frames = yes
}
zmn_zhuhou_support_plus_2 = {	#+4 +9
	custom_effect_tooltip = zmn_zhuhou_support_plus_2_tt	
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = 9 }
	clamp_temp_variable = { var = temp_factor min = 4 max = 9 }
	add_to_variable = { zmn_zhuhou_support = temp_factor }
	round_variable = zmn_zhuhou_support
	clamp_variable = { var = zmn_zhuhou_support max = 100 min = 0 }
	zmn_recalc_zhuhou_icon_frames = yes	
}
zmn_zhuhou_support_plus_3 = {	# +7 +13
	custom_effect_tooltip = zmn_zhuhou_support_plus_3_tt	
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = 13 }
	clamp_temp_variable = { var = temp_factor min = 7 max = 13 }
	add_to_variable = { zmn_zhuhou_support = temp_factor }
	round_variable = zmn_zhuhou_support
	clamp_variable = { var = zmn_zhuhou_support max = 100 min = 0 }
	zmn_recalc_zhuhou_icon_frames = yes	
}

zmn_zhuhou_support_minus_1 = {	# -2 -5
	custom_effect_tooltip = zmn_zhuhou_support_minus_1_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = -5 }
	clamp_temp_variable = { var = temp_factor min = -5 max = -2 }
	add_to_variable = { zmn_zhuhou_support = temp_factor }
	round_variable = zmn_zhuhou_support
	clamp_variable = { var = zmn_zhuhou_support max = 100 min = 0 }
	zmn_recalc_zhuhou_icon_frames = yes
}
zmn_zhuhou_support_minus_2 = {	# -4 -9
	custom_effect_tooltip = zmn_zhuhou_support_minus_2_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = -9 }
	clamp_temp_variable = { var = temp_factor min = -9 max = -4 }
	add_to_variable = { zmn_zhuhou_support = temp_factor }
	round_variable = zmn_zhuhou_support
	clamp_variable = { var = zmn_zhuhou_support max = 100 min = 0 }
	zmn_recalc_zhuhou_icon_frames = yes
}
zmn_zhuhou_support_minus_3 = {	# -13 -7
	custom_effect_tooltip = zmn_zhuhou_support_minus_3_tt
	set_temp_variable = { temp_factor = random }
	multiply_temp_variable = { temp_factor = -13 }
	clamp_temp_variable = { var = temp_factor min = -13 max = -7 }
	add_to_variable = { zmn_zhuhou_support = temp_factor }
	round_variable = zmn_zhuhou_support
	clamp_variable = { var = zmn_zhuhou_support max = 100 min = 0 }
	zmn_recalc_zhuhou_icon_frames = yes
}

#рекалл шкалы
zmn_recalc_zhuhou_icon_frames = {	
	set_temp_variable = { zhuhou_temp = zmn_zhuhou_support }
	divide_temp_variable = { zhuhou_temp = 100 }
	multiply_temp_variable = { zhuhou_temp = 21 }
	if = {
		limit = { check_variable = { zhuhou_temp > 0 } }
		clamp_temp_variable = {
			var = zhuhou_temp
			min = 1
			max = 21
		}
	}
	else = {
		set_temp_variable = { zhuhou_temp = 1 }
	}
	set_variable = { current_vrata_icon_frame = zhuhou_temp }	
}