on_actions = {	
	on_startup = {		
		effect = {				
			every_country = {	#история игрового мира
				limit = { is_ai = no }	
				country_event = { id = ar_political.111 }					
			}	
			every_country = {	#считалочка населения на старт игры					
				add_to_variable = { k_naselenie_vsego_start = max_manpower_k }
				divide_variable = {
					var = k_naselenie_vsego_start
					value = 1000
				}
				round_variable = k_naselenie_vsego_start
				add_to_variable = { global.manp_summa_var_1986 = k_naselenie_vsego_start }				
#				set_variable = { var_capital_num = capital }
			}
			
			ZHA = {
				if = {
					limit = {						
						has_game_rule = {
							rule = ZHA_ai_behavior
							option = ZHA_TECHNOKRAT_RUL
						}
					}
					ZHA = {
						set_country_flag = ZHA_TECHNOKRAT_RUL_FLAG
					}
				}
				if = {
					limit = {						
						has_game_rule = {
							rule = ZHA_ai_behavior
							option = ZHA_IMPERITRICS
						}
					}
					ZHA = {
						set_country_flag = ZHA_IMPERITRICS_FLAG
					}
				}
			}	
			ZRI = {
				if = {
					limit = {						
						has_game_rule = {
							rule = ZRI_AI_BEHAVIOR
							option = IMPERATORLOOSER
						}
					}
					ZRI = {
						set_country_flag = ZRI_IMPERATORLOOSER_RUL_flag
					}
				}
				if = {
					limit = {						
						has_game_rule = {
							rule = ZRI_AI_BEHAVIOR
							option = IMPERIUM
						}
					}
					ZRI = {
						set_country_flag = ZRI_IMPERIUM_RUL_flag
					}
				}
			}
			ZBA = {
				if = {
					limit = {						
						has_game_rule = {
							rule = ZBA_AI_BEHAVIOR
							option = ZBA_FEDERAT_RUL
						}
					}
					ZBA = {
						set_country_flag = ZBA_FEDERAT_RUL_flag
					}
				}
				if = {
					limit = {						
						has_game_rule = {
							rule = ZBA_AI_BEHAVIOR
							option = ZBA_KONFEDERAT_RUL
						}
					}
					ZBA = {
						set_country_flag = ZBA_KONFEDERAT_RUL_flag
					}
				}
				if = {
					limit = {						
						has_game_rule = {
							rule = ZBA_AI_BEHAVIOR
							option = ZBA_TEUTON_RUL
						}
					}
					ZBA = {
						set_country_flag = ZBA_TEUTON_RUL_flag
					}
				}
				if = {
					limit = {						
						has_game_rule = {
							rule = ZBA_AI_BEHAVIOR
							option = ZBA_RASPAD_RUL
						}
					}
					ZBA = {
						set_country_flag = ZBA_RASPAD_RUL_flag
					}
				}
			}
			ZSL = {
				if = {
					limit = {						
						has_game_rule = {
							rule = ZSL_AI_BEHAVIOR
							option = ZSL_NATIWAY
						}
					}
					ZSL = {
						set_country_flag = ZSL_NATIWAY_flag
					}
				}
				if = {
					limit = {						
						has_game_rule = {
							rule = ZSL_AI_BEHAVIOR
							option = ZSL_FEDERAT
						}
					}
					ZSL = {
						set_country_flag = ZSL_FEDERAT_flag
					}
				}
				if = {
					limit = {						
						has_game_rule = {
							rule = ZSL_AI_BEHAVIOR
							option = ZSL_RESPUBL
						}
					}
					ZSL = {
						set_country_flag = ZSL_RESPUBL_flag
					}
				}
				if = {
					limit = {						
						has_game_rule = {
							rule = ZSL_AI_BEHAVIOR
							option = ZSL_FANATIC
						}
					}
					ZSL = {
						set_country_flag = ZSL_FANATIC_flag
					}
				}
			}
			ZOR = {
				if = {
					limit = {						
						has_game_rule = {
							rule = ZOR_AI_BEHAVIOR
							option = ZOR_KONSERVA_RUL
						}
					}
					ZOR = {
						set_country_flag = ZOR_KONSERVA_RUL_flag
					}
				}
				if = {
					limit = {						
						has_game_rule = {
							rule = ZOR_AI_BEHAVIOR
							option = ZOR_DEMOCR_BOGULU
						}
					}
					ZOR = {
						set_country_flag = ZOR_DEMOCR_BOGULU_flag
					}
				}
				if = {
					limit = {						
						has_game_rule = {
							rule = ZOR_AI_BEHAVIOR
							option = ZOR_DEMOCR_OROSKILD
						}
					}
					ZOR = {
						set_country_flag = ZOR_DEMOCR_OROSKILD_flag
					}
				}
			}
#			ZMP = {		# лунтик )0))
#				if = {
#					limit = {						
#						has_game_rule = {
#							rule = ZZR_AI_BEHAVIOR
#							option = ZZR_MEST_RUL
#						}
#					}
#					ZMP = {
#						country_event = { days = 10 id = wtf_event.21 }
#					}
#				}				
#			}
			ZMN = {
				if = {
					limit = {						
						has_game_rule = {
							rule = ZMN_AI_BEHAVIOR
							option = ZMN_UPERTY_MONARCH
						}
					}
					ZMN = {
						set_country_flag = ZMN_UPERTY_MONARCH_flag
					}
				}
				if = {
					limit = {						
						has_game_rule = {
							rule = ZMN_AI_BEHAVIOR
							option = ZMN_CHU_MONARCH
						}
					}
					ZMN = {
						set_country_flag = ZMN_CHU_MONARCH_flag
					}
				}
				if = {
					limit = {						
						has_game_rule = {
							rule = ZMN_AI_BEHAVIOR
							option = ZMN_UE_MONARCH
						}
					}
					ZMN = {
						set_country_flag = ZMN_UE_MONARCH_flag
					}
				}
				if = {
					limit = {						
						has_game_rule = {
							rule = ZMN_AI_BEHAVIOR
							option = ZMN_SHU_MONARCH
						}
					}
					ZMN = {
						set_country_flag = ZMN_SHU_MONARCH_flag
					}
				}
				if = {
					limit = {						
						has_game_rule = {
							rule = ZMN_AI_BEHAVIOR
							option = ZMN_MIN_MONARCH
						}
					}
					ZMN = {
						set_country_flag = ZMN_MIN_MONARCH_flag
					}
				}
				if = {
					limit = {						
						has_game_rule = {
							rule = ZMN_AI_BEHAVIOR
							option = ZMN_PEREKAT_V_OMNIKOV
						}
					}
					ZMN = {
						country_event = { days = 25 id = jungo.300 }
					}
				}
				if = {
					limit = {						
						has_game_rule = {
							rule = ZMN_AI_BEHAVIOR
							option = ZMN_PEREKAT_V_DEMOV
						}
					}
					ZMN = {
						country_event = { days = 25 id = jungo.301 }
					}
				}
			}
			ZAR = {
				if = {
					limit = {						
						has_game_rule = {
							rule = ZAR_AI_BEHAVIOR
							option = ZAR_SULTAN_RUL
						}
					}
					set_country_flag = ZAR_SULTAN_RUL_flag
				}
			}	
			#	
			every_country = {	# Халифат
				limit = { has_country_flag = ar_caliphate_cat_flag }	
				ar_caliphate_recall_victory_points = yes					
			}
		}		
	}
	
	on_puppet = { 
		effect = {
			if = {
				limit = { 				 
					OR = {
						original_tag = ZBE
						original_tag = ZKA	
						original_tag = ZAL	
						original_tag = ZKL	
						original_tag = XMZ	
						original_tag = ZAU	
						original_tag = ZKT		
						original_tag = ZGL		
						original_tag = ZAV	
						original_tag = ALB			
						original_tag = XAU		
						original_tag = ZWI	
						original_tag = ZDI		
						original_tag = ZKG	
						original_tag = ZRI
						original_tag = ZSL
						original_tag = ZPE
					}
#					NOT = {
#						is_puppet_of = ZRI
#					}
				}
				drop_cosmetic_tag = yes					
			}
			set_variable = { zth_dolya_v_ekonomike_var = 0 }	# переменная доли экономики у корпорации синька
			zth_probros_modifikatorov_ot_korporatii = yes
		}
	}
	on_puppet = { 
		effect = {
			if = {
				limit = { 				 
					original_tag = ZBO
					FROM = {
						original_tag = ZBR						
						has_country_leader = { character = ZBR_joseph_von_brandenburg }
						has_character = ZBR_waldemar_hindenburg
					}
				}
				retire_country_leader = yes
				# ZBR = {
					# ZBR_waldemar_hindenburg = {
						# set_nationality = ZBO
					# }	
				# }
				
			}			
		}
	}
	on_capitulation = {
		effect = {
			if = {
				limit = {					
					has_idea = zth_sotrudnichestvo_s_korporatami				
				}
				remove_ideas = zth_sotrudnichestvo_s_korporatami
			}			
		}		
	}
	on_leave_faction = { 
		effect = {
			if = {
				limit = {
					original_tag = ZLU
				}
				set_variable = { global.zlu_infl = 0 } 
			}	
			if = {
				limit = {
					original_tag = ZFR
				}
				set_variable = { global.zfr_infl = 0 } 
			}
			if = {
				limit = {
					original_tag = ZHM
				}
				set_variable = { global.zhm_infl = 0 } 
			}
			if = {
				limit = {
					original_tag = ZJT
				}
				set_variable = { global.zjt_infl = 0 } 
			}
		}	
	}
	
	on_government_change = {	#сбрасывалка фокусов
		effect = {
			country_event = { id = ar_political.806 days = 1 }
		}	
	}
	
	on_puppet = {	#сбрасывалка фокусов
		effect = {
			country_event = { id = ar_political.806 days = 1 }
		}	
	}
	
	on_subject_free = {
		effect = {
			if = {
				limit = {					
					original_tag = ZTA					
				}
				set_party_name = { 
					ideology = fascism 
					long_name = ZTA_fascism_party 
					name = ZTA_fascism_party 
				}
			}
		}
	}
	
	#FROM is war target
	on_declare_war = {
		effect = {
			if = {
				limit = {
					FROM = {
						has_country_flag = pod_kolpakom_u_zmn_ue_flag
						capital_scope = {
							OR = {
								is_on_continent = asia
								is_on_continent = north_america
								is_on_continent = south_america
							}
						}
					}
					NOT = { 
						tag = ZMN
						is_in_faction_with = ZMN # I guess ZMN will not go to war with someone they are in faction with
						has_war_with = ZMN
						#ZMN = { has_war_with = FROM } Should ZMN enforce peace in a nation it is already at war with?
					}
					has_country_flag = pod_kolpakom_u_zmn_ue_flag
					capital_scope = {						
						OR = {
							is_on_continent = asia
							is_on_continent = north_america
							is_on_continent = south_america
						}
					}
				}				
				FROM = { country_event = { id = jungo.180 days = 2 } }
			}
		}
	}	
	
	on_nuke_drop = {		
		effect = {
			if = {
				limit = {
#					has_global_flag = ar_atomic_annihilation_glob_flag
					has_game_rule = {
						rule = AR_ATOMIC_ANNIH
						option = AR_ATOMIC_ANNIH_ON
					}
				}
				every_country = {
					delete_unit = { 
						state = FROM
					} 
				}
				if = {
					limit = {
						FROM = {
							state_population  > 250000
						}
					}
					FROM = {
						add_manpower = -248412
					}
					add_to_variable = { global.jertvy_voin = 248412 }
				}
				else_if = {
					limit = {
						FROM = {
							state_population  > 100000
						}
					}
					FROM = {
						add_manpower = -87741
					}
					add_to_variable = { global.jertvy_voin = 87741 }
				}
				else_if = {
					limit = {
						FROM = {
							state_population  > 55000
						}
					}
					FROM = {
						add_manpower = -54741
					}
					add_to_variable = { global.jertvy_voin = 54741 }
				}
				###
				if = {
					limit = {
						FROM = {
							arms_factory > 0
						}
					}
					FROM = {
						remove_building = {
							type = arms_factory
							level = 1
						}
					}					
				}
				if = {
					limit = {
						FROM = {
							industrial_complex > 0
						}
					}
					FROM = {
						remove_building = {
							type = industrial_complex
							level = 1
						}
					}					
				}
				if = {
					limit = {
						FROM = {
							dockyard > 0
						}
					}
					FROM = {
						remove_building = {
							type = dockyard
							level = 1
						}
					}					
				}
			}
		}
	}	
	
	###
	on_weekly = {
		effect = {
			every_country = {	# Халифат
				limit = { has_country_flag = ar_caliphate_cat_flag }	
				ar_caliphate_recall_victory_points = yes					
			}
		
		}
	
	}
	
	on_release_as_puppet = {
		effect = {
			if = {
				limit = {
					FROM = {
						tag = ZMN
					}				
				}
				country_lock_all_division_template = no
				division_template = {
					name = "Self Defense Forces"					
					regiments = {
						infantry = { x = 0 y = 0 }
						infantry = { x = 0 y = 1 }
						infantry = { x = 0 y = 2 }
						infantry = { x = 0 y = 3 }
					}					 
				}
			}	
		}	
	}
	on_release_as_free = {
		effect = {
			if = {
				limit = {
					FROM = {
						tag = ZMN
					}				
				}
				country_lock_all_division_template = no
				division_template = {
					name = "Self Defense Forces"					
					regiments = {
						infantry = { x = 0 y = 0 }
						infantry = { x = 0 y = 1 }
						infantry = { x = 0 y = 2 }
						infantry = { x = 0 y = 3 }
					}					 
				}
			}	
		}	
	}
		
	on_weekly_ZBO = {
    	effect = {
        	if = {
         	    limit = { 
            		#tag = ZBO
					ZBO = {
						controls_province = 9904
						has_completed_focus = zbo_pope_vliyat
					}
					
            	}
				every_country = {
					limit = {
						ROOT = {
							any_owned_state = {
								is_on_continent = europe
								is_controlled_by = PREV
							}
							NOT = {
								is_puppet_of = ZBO
								tag = ZBO
							}	
						}
					}
					country_event = bemen.146	
				}	
			}
			
    	}
	}
	on_weekly_ZBO = {
    	effect = {
        	if = {
         	    limit = { 
            		#tag = ZBO
					ZBO = {
						controls_state = 137
						has_completed_focus = zbo_njet_evreyam
						NOT = { has_country_flag = zbo_njet_evreyam_cf }
						OR = {
							ZKR = { is_puppet_of = ZBO }
							NOT = { country_exists = ZKR }
						}
					}	
            	}
				country_event = bemen.147
			}				
    	}
	}
}	
		
		