﻿# Economic events
add_namespace = econvent
add_namespace = econvent_remove_flag
add_namespace = bankrupcy
add_namespace = News_bankrupcy
add_namespace = influence
add_namespace = News_influence

### Contents ###
# 1-5 Financial Crisis / Economic Collapse Chain
# 6-> Smaller Adjustments
# ?-> Droughts and poor Global South specific economic events

### Planned Additions ###
# IMF / BRICS-Bank conditional assistance
# ASEAN: Access ASEAN+3 Crisis funds feature
# EU: Ask for help from ECU (esp. if high debt)
# Make crisises in larger neigbour countries affect situation, especially IF ingame friends and have trade
# Flavor events for high debt situations
# Add in pics and better texts

### Influence Action events ###

country_event = {
	id = influence.0
	title = influence.0.t
	desc = influence.0.d
	#picture = GFX_united_states_dollar
	
	is_triggered_only = yes
	hidden = yes
	
	immediate = {
		set_variable = { gift_sum = size_modifier }
		multiply_variable = { gift_sum = 10 }
		clamp_variable = {
			var = gift_sum
			min = 1
			max = 5000
		}
		FROM = { country_event = { id = influence.1 } }
	}

	option = {
		name = influence.0.a
		log = "[GetDateText]: [This.GetName]: influence.0.a executed"
	}
}
							
country_event = {
	id = influence.11
	title = influence.11.t
	desc = influence.11.d
	#picture = GFX_united_states_dollar
	
	is_triggered_only = yes
	hidden = yes
	
	immediate = {
		set_variable = { gift_sum = size_modifier }
		multiply_variable = { gift_sum = 10 }
		clamp_variable = {
			var = gift_sum
			min = 1
			max = 5000
		}
		event_target:influence_sender = { country_event = { id = influence.1 } }
	}

	option = {
		name = influence.0.a
		log = "[GetDateText]: [This.GetName]: influence.0.a executed"
	}
}

country_event = {
	id = influence.1
	title = influence.1.t
	desc = influence.1.d
	picture = GFX_united_states_dollar
	
	is_triggered_only = yes
	
	immediate = {
	}
	
	#Give it
	option = {
		name = influence.1.a
		log = "[GetDateText]: [This.GetName]: influence.1.a executed"
		ai_chance = {
			factor = 10
		}
		custom_effect_tooltip = influence_0_TT
		subtract_from_variable = { treasury = FROM.gift_sum }

		custom_effect_tooltip = aid_influence_gain_relative_TT
		
		reverse_add_opinion_modifier = {
				target = FROM
				modifier = given_gift
		}
		FROM = {
			#influence addition
			set_temp_variable = { influence_gain = ROOT.influence_multiplier } #from global rank idea
			multiply_temp_variable = { influence_gain = 5 } #base gain
			for_loop_effect = {
				end = influence_array^num
				value = v
				if = {
					limit = {
						check_variable = { influence_array^v = ROOT }
					}
					add_to_variable = { influence_array_val^v = influence_gain }
					set_country_flag = found
				}
			}
			if = {
				limit = { NOT = { has_country_flag = found } }
					add_to_array = { influence_array = ROOT.id }
					add_to_array = { influence_array_val = influence_gain }
			}
			clr_country_flag = found
			recalculate_influence = yes
			news_event = { id = News_influence.0 } 
		}
	}
	#Let's not bother
	option = {
		name = influence.1.b
		log = "[GetDateText]: [This.GetName]: influence.1.b executed"
		ai_chance = { factor = 0 }
	}
}


news_event = {
	id = News_influence.0
	title = News_influence.0.t
	desc = News_influence.0.d
	picture = GFX_update_gdpc
	
	is_triggered_only = yes
	
	immediate = {
	}
	
	#yeah...
	option = {
		name = News_influence.0.a
		log = "[GetDateText]: [This.GetName]: News_influence.0.a executed"
		custom_effect_tooltip = influence_from_0_TT
		add_to_variable = { treasury = gift_sum }
	}
}

### target specific influence
country_event = {
	id = influence.2
	title = influence.2.t
	desc = influence.2.d
	#picture = GFX_united_states_dollar
	
	is_triggered_only = yes
	hidden = yes
	
	immediate = {
		FROM = { country_event = { id = influence.3 } }
	}

	option = {
		name = influence.2.a
		log = "[GetDateText]: [This.GetName]: influence.2.a executed"
	}
}

country_event = {
	id = influence.22
	title = influence.22.t
	desc = influence.22.d
	#picture = GFX_united_states_dollar
	
	is_triggered_only = yes
	hidden = yes
	
	immediate = {
		event_target:influence_sender = { country_event = { id = influence.3 } }
	}

	option = {
		name = influence.2.a
		log = "[GetDateText]: [This.GetName]: influence.2.a executed"
	}
}


country_event = {
	id = influence.3
	title = influence.3.t
	desc = influence.3.d
	picture = GFX_politics_surveillence
	
	is_triggered_only = yes
	
	immediate = {
	}
	
	#Target domestic influence
	option = {
		name = influence.3.a
		log = "[GetDateText]: [This.GetName]: influence.3.a executed"
		ai_chance = {
			factor = 11
		}
		
		FROM = {
				news_event = { id = News_influence.2 }
		}
		custom_effect_tooltip = influence_3_a_TT
		FROM = {
			
			# remove 1% of target influence
			set_temp_variable = { influence_reduce = influence_total } #from global rank idea
			multiply_temp_variable = { influence_reduce = 0.01 } #1%
			subtract_from_variable = { domestic_influence_amount = influence_reduce }
			subtract_from_variable = { domestic_influence_amount = 10 } #+10 fixed reduction
			clamp_variable = {
				var = domestic_influence_amount
				min = 0
				max = influence_total
			}
		
			#ROOT remove 1% influence
			set_temp_variable = { influence_reduce = influence_total } #from global rank idea
			multiply_temp_variable = { influence_reduce = 0.01 } #1%
			for_loop_effect = {
				end = influence_array^num
				value = v
				if = {
					limit = {
						check_variable = { influence_array^v = ROOT }
					}
					subtract_from_variable = { influence_array_val^v = influence_reduce }
					#SAFEGUARD: remove if negative
					if = {
						limit = {
							check_variable = { influence_array_val^v < 0 }
						}
						remove_from_array = {
							array = influence_array
							index = v
						}
						remove_from_array = {
							array = influence_array_val
							index = v
						}
						remove_from_array = {
							array = influence_array_calc
							index = v
						}
					}
				}
			}
			recalculate_influence = yes
		}
		add_political_power = -100
	}
	
	#Target biggest influencer
	option = {
		name = influence.3.b
		log = "[GetDateText]: [This.GetName]: influence.3.b executed"
		ai_chance = {
			factor = 10
		}
		trigger = {
			FROM = {
				has_variable = influence_array^0
				NOT = {
					check_variable = { influence_array^0 = ROOT }
				}
			}
		}
		
		var:FROM.influence_array^0 = {
				news_event = { id = News_influence.1 }
		}
		custom_effect_tooltip = influence_3_b_TT
		FROM = {
			
			#ROOT remove 1% of target influencer
			set_temp_variable = { influence_reduce = influence_total } #from global rank idea
			multiply_temp_variable = { influence_reduce = 0.01 } #1%
			subtract_from_variable = { influence_array_val^0 = influence_reduce }
			subtract_from_variable = { influence_array_val^0 = 10 } #+10 fixed reduction
			#SAFEGUARD: remove if negative
			if = {
				limit = {
					check_variable = { influence_array_val^0 < 0 }
				}
				remove_from_array = {
					array = influence_array
					index = 0
				}
				remove_from_array = {
					array = influence_array_val
					index = 0
				}
				remove_from_array = {
					array = influence_array_calc
					index = 0
				}
			}
		
			#ROOT remove 1% influence
			set_temp_variable = { influence_reduce = influence_total } #from global rank idea
			multiply_temp_variable = { influence_reduce = 0.01 } #1%
			for_loop_effect = {
				end = influence_array^num
				value = v
				if = {
					limit = {
						check_variable = { influence_array^v = ROOT }
					}
					subtract_from_variable = { influence_array_val^v = influence_reduce }
					#SAFEGUARD: remove if negative
					if = {
						limit = {
							check_variable = { influence_array_val^v < 0 }
						}
						remove_from_array = {
							array = influence_array
							index = v
						}
						remove_from_array = {
							array = influence_array_val
							index = v
						}
						remove_from_array = {
							array = influence_array_calc
							index = v
						}
					}
				}
			}
			recalculate_influence = yes
		}
		add_political_power = -100
	}
	#Target 2nd biggest influencer
	option = {
		name = influence.3.c
		log = "[GetDateText]: [This.GetName]: influence.3.c executed"
		ai_chance = {
			factor = 6
		}
		trigger = {
			FROM = {
				has_variable = influence_array^1
				NOT = {
					check_variable = { influence_array^1 = ROOT }
				}
			}
		}
		
		var:FROM.influence_array^1 = {
				news_event = { id = News_influence.1 }
		}
		custom_effect_tooltip = influence_3_c_TT
		FROM = {
			
			#ROOT remove 1% of target influencer
			set_temp_variable = { influence_reduce = influence_total } #from global rank idea
			multiply_temp_variable = { influence_reduce = 0.01 } #1%
			subtract_from_variable = { influence_array_val^1 = influence_reduce }
			subtract_from_variable = { influence_array_val^1 = 10 } #+10 fixed reduction
			#SAFEGUARD: remove if negative
			if = {
				limit = {
					check_variable = { influence_array_val^1 < 0 }
				}
				remove_from_array = {
					array = influence_array
					index = 1
				}
				remove_from_array = {
					array = influence_array_val
					index = 1
				}
				remove_from_array = {
					array = influence_array_calc
					index = 0
				}
			}
		
			#ROOT remove 1% influence
			set_temp_variable = { influence_reduce = influence_total } #from global rank idea
			multiply_temp_variable = { influence_reduce = 0.01 } #1%
			for_loop_effect = {
				end = influence_array^num
				value = v
				if = {
					limit = {
						check_variable = { influence_array^v = ROOT }
					}
					subtract_from_variable = { influence_array_val^v = influence_reduce }
					#SAFEGUARD: remove if negative
					if = {
						limit = {
							check_variable = { influence_array_val^v < 0 }
						}
						remove_from_array = {
							array = influence_array
							index = v
						}
						remove_from_array = {
							array = influence_array_val
							index = v
						}
						remove_from_array = {
							array = influence_array_calc
							index = v
						}
					}
				}
			}
			recalculate_influence = yes
		}
		add_political_power = -100
	}
	
	option = {
		name = influence.3.e
		log = "[GetDateText]: [This.GetName]: influence.3.e executed"
		ai_chance = {
			factor = 3
		}
		trigger = {
			FROM = {
				has_variable = influence_array^2
				NOT = {
					check_variable = { influence_array^2 = ROOT }
				}
			}
		}
		
		var:FROM.influence_array^2 = {
				news_event = { id = News_influence.1 }
		}
		custom_effect_tooltip = influence_3_e_TT
		FROM = {
			
			#ROOT remove 1% of target influencer
			set_temp_variable = { influence_reduce = influence_total } #from global rank idea
			multiply_temp_variable = { influence_reduce = 0.01 } #1%
			subtract_from_variable = { influence_array_val^2 = influence_reduce }
			subtract_from_variable = { influence_array_val^2 = 10 } #+10 fixed reduction
			#SAFEGUARD: remove if negative
			if = {
				limit = {
					check_variable = { influence_array_val^2 < 0 }
				}
				remove_from_array = {
					array = influence_array
					index = 2
				}
				remove_from_array = {
					array = influence_array_val
					index = 2
				}
				remove_from_array = {
					array = influence_array_calc
					index = 2
				}
			}
		
			#ROOT remove 1% influence
			set_temp_variable = { influence_reduce = influence_total } #from global rank idea
			multiply_temp_variable = { influence_reduce = 0.01 } #1%
			for_loop_effect = {
				end = influence_array^num
				value = v
				if = {
					limit = {
						check_variable = { influence_array^v = ROOT }
					}
					subtract_from_variable = { influence_array_val^v = influence_reduce }
					#SAFEGUARD: remove if negative
					if = {
						limit = {
							check_variable = { influence_array_val^v < 0 }
						}
						remove_from_array = {
							array = influence_array
							index = v
						}
						remove_from_array = {
							array = influence_array_val
							index = v
						}
						remove_from_array = {
							array = influence_array_calc
							index = v
						}
					}
				}
			}
			recalculate_influence = yes
		}
		add_political_power = -100
	}
	#Let's not bother
	option = {
		name = influence.3.f
		log = "[GetDateText]: [This.GetName]: influence.3.f executed"
		ai_chance = { factor = 0 }
	}
}

# attacked our influence in another country
news_event = {
	id = News_influence.1
	title = News_influence.1.t
	desc = News_influence.1.d
	picture = GFX_crime_fighting
	
	is_triggered_only = yes
	
	immediate = {
	}
	
	#yeah...
	option = {
		name = News_influence.1.a
		log = "[GetDateText]: [This.GetName]: News_influence.1.a executed"
		add_opinion_modifier = {
				target = FROM
				modifier = attacked_our_influence
		}
	}
}

# attacked our domestic influence
news_event = {
	id = News_influence.2
	title = News_influence.2.t
	desc = News_influence.2.d
	picture = GFX_crime_fighting
	
	is_triggered_only = yes
	
	immediate = {
	}
	
	#yeah...
	option = {
		name = News_influence.2.a
		log = "[GetDateText]: [This.GetName]: News_influence.2.a executed"
		add_opinion_modifier = {
				target = FROM
				modifier = attacked_our_influence
		}
	}
}

### Coup! ###

#target
country_event = {
	id = influence.4
	title = influence.4.t
	desc = influence.4.d
	#picture = GFX_united_states_dollar
	
	is_triggered_only = yes
	hidden = yes
	
	immediate = {
		
		### Chance of failure for ROOT add-up ###
		for_loop_effect = {
			end = influence_array_calc^num
			if = {
				limit = { var:influence_array^v = { has_government = democratic } }
				add_to_temp_variable = { influence_democratic = influence_array_calc^v }	
			}
			else_if = {
				limit = { var:influence_array^v = { has_government = neutrality } }
				add_to_temp_variable = { influence_neutrality = influence_array_calc^v }	
			}
			else_if = {
				limit = { var:influence_array^v = { has_government = communism } }
				add_to_temp_variable = { influence_communism = influence_array_calc^v }	
			}
			else_if = {
				limit = { var:influence_array^v = { has_government = nationalist } }
				add_to_temp_variable = { influence_nationalist = influence_array_calc^v }	
			}
			else_if = {
				limit = { var:influence_array^v = { has_government = fascism } }
				add_to_temp_variable = { influence_fascism = influence_array_calc^v }	
			}
		}
		#
		
		set_variable = { fail_factor_biggest = party_popularity@ruling_party }
		divide_variable = { fail_factor_biggest = 100 }
		
		if = {
			limit = { has_government = democratic }
			add_to_variable = { fail_factor_biggest = influence_democratic }
			add_to_variable = { fail_factor_biggest = domestic_influence_amount_calc }
		}
		else_if = {
			limit = { has_government = neutrality }
			add_to_variable = { fail_factor_biggest = influence_neutrality }
			add_to_variable = { fail_factor_biggest = domestic_influence_amount_calc }
		}
		else_if = {
			limit = { has_government = communism }
			add_to_variable = { fail_factor_biggest = influence_communism }
			add_to_variable = { fail_factor_biggest = domestic_influence_amount_calc }
		}
		else_if = {
			limit = { has_government = nationalist }
			add_to_variable = { fail_factor_biggest = influence_nationalist }
			add_to_variable = { fail_factor_biggest = domestic_influence_amount_calc }
		}
		else_if = {
			limit = { has_government = fascism }
			add_to_variable = { fail_factor_biggest = influence_fascism }
			add_to_variable = { fail_factor_biggest = domestic_influence_amount_calc }
		}
		set_temp_variable = { add_factor = size_modifier }
		divide_temp_variable = { add_factor = 7 }
		add_to_temp_variable = { add_factor = 1 }
		multiply_variable = { fail_factor_biggest = add_factor }
		
		### Chance of success for ROOT add-up ###
		if = {
			limit = { FROM = { has_government = democratic } }
			
			set_variable = { success_factor_biggest = party_popularity@democratic }
			divide_variable = { success_factor_biggest = 100 }
			add_to_variable = { success_factor_biggest = influence_democratic }
			
			#storing biggest party
			set_temp_variable = { prevmax_temp = 0 }
			if = {
				limit = {
					has_variable = party_pop_array^1
					check_variable = { party_pop_array^1 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^1 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^2
					check_variable = { party_pop_array^2 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^2 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^3
					check_variable = { party_pop_array^3 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^3 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^0
					check_variable = { party_pop_array^0 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^0 }
			}
			#Set for highest value
			if = { limit = { check_variable = { prevmax_temp = party_pop_array^1 } }
				set_country_flag = set_conservatism
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^2 } }
				set_country_flag = set_liberalism
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^3 } }
				set_country_flag = set_socialism
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^0 } }
				set_country_flag = set_Western_Autocracy
			}
		}
		else_if = {
			limit = { FROM = { has_government = neutrality } }
			
			set_variable = { success_factor_biggest = party_popularity@neutrality }
			divide_variable = { success_factor_biggest = 100 }
			add_to_variable = { success_factor_biggest = influence_neutrality }
			
			#storing biggest party
			set_temp_variable = { prevmax_temp = 0 }
			if = {
				limit = {
					has_variable = party_pop_array^14
					check_variable = { party_pop_array^14 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^14 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^15
					check_variable = { party_pop_array^15 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^15 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^18
					check_variable = { party_pop_array^18 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^18 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^16
					check_variable = { party_pop_array^16 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^16 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^13
					check_variable = { party_pop_array^13 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^13 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^19
					check_variable = { party_pop_array^19 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^19 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^17
					check_variable = { party_pop_array^17 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^17 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^12
					check_variable = { party_pop_array^12 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^12 }
			}
			
			#Set for highest value
			if = { limit = { check_variable = { prevmax_temp = party_pop_array^14 } }
				set_country_flag = set_Neutral_conservatism
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^15 } }
				set_country_flag = set_oligarchism
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^18 } }
				set_country_flag = set_neutral_Social
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^16 } }
				set_country_flag = set_Neutral_Libertarian
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^13 } }
				set_country_flag = set_Neutral_Autocracy
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^19 } }
				set_country_flag = set_Neutral_Communism
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^17 } }
				set_country_flag = set_Neutral_Muslim_Brotherhood
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^12 } }
				set_country_flag = set_Neutral_green
			}
		}
		else_if = {
			limit = { FROM = { has_government = communism } }
			
			set_variable = { success_factor_biggest = party_popularity@communism }
			divide_variable = { success_factor_biggest = 100 }
			add_to_variable = { success_factor_biggest = influence_communism }
			
			#storing biggest party
			set_temp_variable = { prevmax_temp = 0 }
			if = {
				limit = {
					has_variable = party_pop_array^4
					check_variable = { party_pop_array^4 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^4 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^6
					check_variable = { party_pop_array^6 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^6 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^7
					check_variable = { party_pop_array^7 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^7 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^9
					check_variable = { party_pop_array^9 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^9 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^8
					check_variable = { party_pop_array^8 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^8 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^5
					check_variable = { party_pop_array^5 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^5 }
			}
			
			#Set for highest value
			if = { limit = { check_variable = { prevmax_temp = party_pop_array^4 } }
				set_country_flag = set_Communist-State
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^6 } }
				set_country_flag = set_Conservative
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^7 } }
				set_country_flag = set_Autocracy
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^9 } }
				set_country_flag = set_Vilayat_e_Faqih
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^8 } }
				set_country_flag = set_Mod_Vilayat_e_Faqih
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^5 } }
				set_country_flag = set_anarchist_communism
			}
		}
		else_if = {
			limit = { FROM = { has_government = nationalist } }
			
			set_variable = { success_factor_biggest = party_popularity@nationalist }
			divide_variable = { success_factor_biggest = 100 }
			add_to_variable = { success_factor_biggest = influence_nationalist }
			
			#storing biggest party
			set_temp_variable = { prevmax_temp = 0 }
			if = {
				limit = {
					has_variable = party_pop_array^22
					check_variable = { party_pop_array^22 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^22 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^21
					check_variable = { party_pop_array^21 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^21 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^20
					check_variable = { party_pop_array^20 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^20 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^23
					check_variable = { party_pop_array^23 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^23 }
			}
			#Set for highest value
			if = { limit = { check_variable = { prevmax_temp = party_pop_array^22 } }
				set_country_flag = set_Nat_Autocracy
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^21 } }
				set_country_flag = set_Nat_Fascism
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^20 } }
				set_country_flag = set_Nat_Populism
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^23 } }
				set_country_flag = set_Monarchist
			}
		}
		else_if = {
			limit = { FROM = { has_government = fascism } }
			
			set_variable = { success_factor_biggest = party_popularity@fascism }
			divide_variable = { success_factor_biggest = 100 }
			add_to_variable = { success_factor_biggest = influence_fascism }
			
			#storing biggest party
			set_temp_variable = { prevmax_temp = 0 }
			if = {
				limit = {
					has_variable = party_pop_array^10
					check_variable = { party_pop_array^10 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^10 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^11
					check_variable = { party_pop_array^11 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^11 }
			}
			#Set for highest value
			if = { limit = { check_variable = { prevmax_temp = party_pop_array^10 } }
				set_country_flag = set_Kingdom
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^11 } }
				set_country_flag = set_Caliphate
			}
		}
		for_loop_effect = {
			end = influence_array^num
			value = v
			if = {
				limit = {
					check_variable = { influence_array^v = FROM }
				}
				add_to_variable = { success_factor_biggest = influence_array_calc^v }
			}
		}
		
		### Chance of civil war ###
		set_variable = { civil_war_factor = stability }
		multiply_variable = { civil_war_factor = -1 }
		add_to_variable = { civil_war_factor = 1 }
		if = {
			limit = {
				check_variable = { gdp_capita < 2 }
			}
			multiply_variable = { civil_war_factor = 1.3 }
		}
		if = {
			limit = {
				check_variable = { gdp_capita > 3 }
			}
			multiply_variable = { civil_war_factor = 0.9 }
		}
		if = {
			limit = {
				check_variable = { gdp_capita > 5 }
			}
			multiply_variable = { civil_war_factor = 0.8 }
		}
		if = {
			limit = {
				check_variable = { gdp_capita > 7 }
			}
			multiply_variable = { civil_war_factor = 0.7 }
		}
		if = {
			limit = {
				check_variable = { gdp_capita > 9 }
			}
			multiply_variable = { civil_war_factor = 0.7 }
		}
	
		FROM = { country_event = { id = influence.5 } }
	}

	option = {
		name = influence.4.a
		log = "[GetDateText]: [This.GetName]: influence.4.a executed"
	}
}

#AI Automated
#target
country_event = {
	id = influence.44
	title = influence.44.t
	desc = influence.44.d
	#picture = GFX_united_states_dollar
	
	is_triggered_only = yes
	hidden = yes
	
	immediate = {
		
		### Chance of failure for ROOT add-up ###
		for_loop_effect = {
			end = influence_array_calc^num
			if = {
				limit = { var:influence_array^v = { has_government = democratic } }
				add_to_temp_variable = { influence_democratic = influence_array_calc^v }	
			}
			else_if = {
				limit = { var:influence_array^v = { has_government = neutrality } }
				add_to_temp_variable = { influence_neutrality = influence_array_calc^v }	
			}
			else_if = {
				limit = { var:influence_array^v = { has_government = communism } }
				add_to_temp_variable = { influence_communism = influence_array_calc^v }	
			}
			else_if = {
				limit = { var:influence_array^v = { has_government = nationalist } }
				add_to_temp_variable = { influence_nationalist = influence_array_calc^v }	
			}
			else_if = {
				limit = { var:influence_array^v = { has_government = fascism } }
				add_to_temp_variable = { influence_fascism = influence_array_calc^v }	
			}
		}
		#
		
		set_variable = { fail_factor_biggest = party_popularity@ruling_party }
		divide_variable = { fail_factor_biggest = 100 }
		
		if = {
			limit = { has_government = democratic }
			add_to_variable = { fail_factor_biggest = influence_democratic }
			add_to_variable = { fail_factor_biggest = domestic_influence_amount_calc }
		}
		else_if = {
			limit = { has_government = neutrality }
			add_to_variable = { fail_factor_biggest = influence_neutrality }
			add_to_variable = { fail_factor_biggest = domestic_influence_amount_calc }
		}
		else_if = {
			limit = { has_government = communism }
			add_to_variable = { fail_factor_biggest = influence_communism }
			add_to_variable = { fail_factor_biggest = domestic_influence_amount_calc }
		}
		else_if = {
			limit = { has_government = nationalist }
			add_to_variable = { fail_factor_biggest = influence_nationalist }
			add_to_variable = { fail_factor_biggest = domestic_influence_amount_calc }
		}
		else_if = {
			limit = { has_government = fascism }
			add_to_variable = { fail_factor_biggest = influence_fascism }
			add_to_variable = { fail_factor_biggest = domestic_influence_amount_calc }
		}
		set_temp_variable = { add_factor = size_modifier }
		divide_temp_variable = { add_factor = 7 }
		add_to_temp_variable = { add_factor = 1 }
		multiply_variable = { fail_factor_biggest = add_factor }
		
		### Chance of success for ROOT add-up ###
		if = {
			limit = { event_target:influence_sender = { has_government = democratic } }
			
			set_variable = { success_factor_biggest = party_popularity@democratic }
			divide_variable = { success_factor_biggest = 100 }
			add_to_variable = { success_factor_biggest = influence_democratic }
			
			#storing biggest party
			set_temp_variable = { prevmax_temp = 0 }
			if = {
				limit = {
					has_variable = party_pop_array^1
					check_variable = { party_pop_array^1 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^1 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^2
					check_variable = { party_pop_array^2 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^2 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^3
					check_variable = { party_pop_array^3 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^3 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^0
					check_variable = { party_pop_array^0 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^0 }
			}
			#Set for highest value
			if = { limit = { check_variable = { prevmax_temp = party_pop_array^1 } }
				set_country_flag = set_conservatism
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^2 } }
				set_country_flag = set_liberalism
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^3 } }
				set_country_flag = set_socialism
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^0 } }
				set_country_flag = set_Western_Autocracy
			}
		}
		else_if = {
			limit = { event_target:influence_sender = { has_government = neutrality } }
			
			set_variable = { success_factor_biggest = party_popularity@neutrality }
			divide_variable = { success_factor_biggest = 100 }
			add_to_variable = { success_factor_biggest = influence_neutrality }
			
			#storing biggest party
			set_temp_variable = { prevmax_temp = 0 }
			if = {
				limit = {
					has_variable = party_pop_array^14
					check_variable = { party_pop_array^14 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^14 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^15
					check_variable = { party_pop_array^15 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^15 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^18
					check_variable = { party_pop_array^18 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^18 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^16
					check_variable = { party_pop_array^16 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^16 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^13
					check_variable = { party_pop_array^13 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^13 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^19
					check_variable = { party_pop_array^19 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^19 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^17
					check_variable = { party_pop_array^17 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^17 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^12
					check_variable = { party_pop_array^12 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^12 }
			}
			
			#Set for highest value
			if = { limit = { check_variable = { prevmax_temp = party_pop_array^14 } }
				set_country_flag = set_Neutral_conservatism
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^15 } }
				set_country_flag = set_oligarchism
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^18 } }
				set_country_flag = set_neutral_Social
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^16 } }
				set_country_flag = set_Neutral_Libertarian
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^13 } }
				set_country_flag = set_Neutral_Autocracy
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^19 } }
				set_country_flag = set_Neutral_Communism
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^17 } }
				set_country_flag = set_Neutral_Muslim_Brotherhood
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^12 } }
				set_country_flag = set_Neutral_green
			}
		}
		else_if = {
			limit = { event_target:influence_sender = { has_government = communism } }
			
			set_variable = { success_factor_biggest = party_popularity@communism }
			divide_variable = { success_factor_biggest = 100 }
			add_to_variable = { success_factor_biggest = influence_communism }
			
			#storing biggest party
			set_temp_variable = { prevmax_temp = 0 }
			if = {
				limit = {
					has_variable = party_pop_array^4
					check_variable = { party_pop_array^4 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^4 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^6
					check_variable = { party_pop_array^6 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^6 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^7
					check_variable = { party_pop_array^7 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^7 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^9
					check_variable = { party_pop_array^9 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^9 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^8
					check_variable = { party_pop_array^8 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^8 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^5
					check_variable = { party_pop_array^5 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^5 }
			}
			
			#Set for highest value
			if = { limit = { check_variable = { prevmax_temp = party_pop_array^4 } }
				set_country_flag = set_Communist-State
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^6 } }
				set_country_flag = set_Conservative
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^7 } }
				set_country_flag = set_Autocracy
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^9 } }
				set_country_flag = set_Vilayat_e_Faqih
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^8 } }
				set_country_flag = set_Mod_Vilayat_e_Faqih
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^5 } }
				set_country_flag = set_anarchist_communism
			}
		}
		else_if = {
			limit = { event_target:influence_sender = { has_government = nationalist } }
			
			set_variable = { success_factor_biggest = party_popularity@nationalist }
			divide_variable = { success_factor_biggest = 100 }
			add_to_variable = { success_factor_biggest = influence_nationalist }
			
			#storing biggest party
			set_temp_variable = { prevmax_temp = 0 }
			if = {
				limit = {
					has_variable = party_pop_array^22
					check_variable = { party_pop_array^22 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^22 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^21
					check_variable = { party_pop_array^21 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^21 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^20
					check_variable = { party_pop_array^20 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^20 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^23
					check_variable = { party_pop_array^23 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^23 }
			}
			#Set for highest value
			if = { limit = { check_variable = { prevmax_temp = party_pop_array^22 } }
				set_country_flag = set_Nat_Autocracy
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^21 } }
				set_country_flag = set_Nat_Fascism
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^20 } }
				set_country_flag = set_Nat_Populism
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^23 } }
				set_country_flag = set_Monarchist
			}
		}
		else_if = {
			limit = { event_target:influence_sender = { has_government = fascism } }
			
			set_variable = { success_factor_biggest = party_popularity@fascism }
			divide_variable = { success_factor_biggest = 100 }
			add_to_variable = { success_factor_biggest = influence_fascism }
			
			#storing biggest party
			set_temp_variable = { prevmax_temp = 0 }
			if = {
				limit = {
					has_variable = party_pop_array^10
					check_variable = { party_pop_array^10 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^10 }
			}
			if = {
				limit = {
					has_variable = party_pop_array^11
					check_variable = { party_pop_array^11 > prevmax_temp }
				}
				set_temp_variable = { prevmax_temp = party_pop_array^11 }
			}
			#Set for highest value
			if = { limit = { check_variable = { prevmax_temp = party_pop_array^10 } }
				set_country_flag = set_Kingdom
			}
			else_if = { limit = { check_variable = { prevmax_temp = party_pop_array^11 } }
				set_country_flag = set_Caliphate
			}
		}
		for_loop_effect = {
			end = influence_array^num
			value = v
			if = {
				limit = {
					check_variable = { influence_array^v = event_target:influence_sender }
				}
				add_to_variable = { success_factor_biggest = influence_array_calc^v }
			}
		}
		
		### Chance of civil war ###
		set_variable = { civil_war_factor = stability }
		multiply_variable = { civil_war_factor = -1 }
		add_to_variable = { civil_war_factor = 1 }
		if = {
			limit = {
				check_variable = { gdp_capita < 2 }
			}
			multiply_variable = { civil_war_factor = 1.3 }
		}
		if = {
			limit = {
				check_variable = { gdp_capita > 3 }
			}
			multiply_variable = { civil_war_factor = 0.9 }
		}
		if = {
			limit = {
				check_variable = { gdp_capita > 5 }
			}
			multiply_variable = { civil_war_factor = 0.8 }
		}
		if = {
			limit = {
				check_variable = { gdp_capita > 7 }
			}
			multiply_variable = { civil_war_factor = 0.7 }
		}
		if = {
			limit = {
				check_variable = { gdp_capita > 9 }
			}
			multiply_variable = { civil_war_factor = 0.7 }
		}
	
		event_target:influence_sender = { country_event = { id = influence.5 } }
	}

	option = {
		name = influence.44.a
		log = "[GetDateText]: [This.GetName]: influence.4.a executed"
	}
}

#root
country_event = {
	id = influence.5
	title = influence.5.t
	desc = influence.5.d
	picture = GFX_politics_surveillence
	
	is_triggered_only = yes
	
	immediate = {
	
	
	
	}
	
	#target outlook - biggest party
	option = {
		name = influence.5.a
		log = "[GetDateText]: [This.GetName]: influence.5.a executed"
		
		
		add_political_power = -200
		
		add_threat = 2
		
		random_list = {
			
			#success
			33.3 = {
				modifier = {
					factor = var:FROM.success_factor_biggest
				}
				custom_effect_tooltip = influence_coup_largest_success_TT
				#add tooltip
				
				FROM = {
					hidden_effect = {
						clear_array = ruling_party
						clear_array = gov_coalition_array
						
						#new gov democratic
						if = {
							limit = { has_country_flag = set_Western_Autocracy }
							add_to_array = { ruling_party = 0 }
							add_popularity = { ideology = democratic popularity = 0.2 }
						}
						else_if = {
							limit = { has_country_flag = set_conservatism }
							add_to_array = { ruling_party = 1 }
							add_popularity = { ideology = democratic popularity = 0.2 }
						}
						else_if = {
							limit = { has_country_flag = set_liberalism }
							add_to_array = { ruling_party = 2 }
							add_popularity = { ideology = democratic popularity = 0.2 }
						}
						else_if = {
							limit = { has_country_flag = set_socialism }
							add_to_array = { ruling_party = 3 }
							add_popularity = { ideology = democratic popularity = 0.2 }
						}
						
						#new gov communism
						else_if = {
							limit = { has_country_flag = set_Communist-State }
							add_to_array = { ruling_party = 4 }
							add_popularity = { ideology = communism popularity = 0.2 }
						}
						else_if = {
							limit = { has_country_flag = set_anarchist_communism }
							add_to_array = { ruling_party = 5 }
							add_popularity = { ideology = communism popularity = 0.2 }
						}
						else_if = {
							limit = { has_country_flag = set_Conservative }
							add_to_array = { ruling_party = 6 }
							add_popularity = { ideology = communism popularity = 0.2 }
						}
						else_if = {
							limit = { has_country_flag = set_Autocracy }
							add_to_array = { ruling_party = 7 }
							add_popularity = { ideology = communism popularity = 0.2 }
						}
						else_if = {
							limit = { has_country_flag = set_Mod_Vilayat_e_Faqih }
							add_to_array = { ruling_party = 8 }
							add_popularity = { ideology = communism popularity = 0.2 }
						}
						else_if = {
							limit = { has_country_flag = set_Vilayat_e_Faqih }
							add_to_array = { ruling_party = 9 }
							add_popularity = { ideology = communism popularity = 0.2 }
						}
						
						#new gov fascism
						else_if = {
							limit = { has_country_flag = set_Kingdom }
							add_to_array = { ruling_party = 10 }
							add_popularity = { ideology = fascism popularity = 0.2 }
						}
						else_if = {
							limit = { has_country_flag = set_Caliphate }
							add_to_array = { ruling_party = 11 }
							add_popularity = { ideology = fascism popularity = 0.2 }
						}
						
						#new gov neutrality
						else_if = {
							limit = { has_country_flag = set_Neutral_Muslim_Brotherhood }
							add_to_array = { ruling_party = 12 }
							add_popularity = { ideology = neutrality popularity = 0.2 }
						}
						else_if = {
							limit = { has_country_flag = set_Neutral_Autocracy }
							add_to_array = { ruling_party = 13 }
							add_popularity = { ideology = neutrality popularity = 0.2 }
						}
						else_if = {
							limit = { has_country_flag = set_Neutral_conservatism }
							add_to_array = { ruling_party = 14 }
							add_popularity = { ideology = neutrality popularity = 0.2 }
						}
						else_if = {
							limit = { has_country_flag = set_oligarchism }
							add_to_array = { ruling_party = 15 }
							add_popularity = { ideology = neutrality popularity = 0.2 }
						}
						else_if = {
							limit = { has_country_flag = set_Neutral_Libertarian }
							add_to_array = { ruling_party = 16 }
							add_popularity = { ideology = neutrality popularity = 0.2 }
						}
						else_if = {
							limit = { has_country_flag = set_Neutral_green }
							add_to_array = { ruling_party = 17 }
							add_popularity = { ideology = neutrality popularity = 0.2 }
						}
						else_if = {
							limit = { has_country_flag = set_neutral_Social }
							add_to_array = { ruling_party = 18 }
							add_popularity = { ideology = neutrality popularity = 0.2 }
						}
						else_if = {
							limit = { has_country_flag = set_Neutral_Communism }
							add_to_array = { ruling_party = 19 }
							add_popularity = { ideology = neutrality popularity = 0.2 }
						}
						
						#new gov nationalist
						else_if = {
							limit = { has_country_flag = set_Nat_Populism }
							add_to_array = { ruling_party = 20 }
							add_popularity = { ideology = nationalist popularity = 0.2 }
						}
						else_if = {
							limit = { has_country_flag = set_Nat_Fascism }
							add_to_array = { ruling_party = 21 }
							add_popularity = { ideology = nationalist popularity = 0.2 }
						}
						else_if = {
							limit = { has_country_flag = set_Nat_Autocracy }
							add_to_array = { ruling_party = 22 }
							add_popularity = { ideology = nationalist popularity = 0.2 }
						}
						else_if = {
							limit = { has_country_flag = set_Monarchist }
							add_to_array = { ruling_party = 23 }
							add_popularity = { ideology = nationalist popularity = 0.2 }
						}
					}
					hidden_effect = {
						set_leader = yes		
						recalculate_party = yes
						hold_elections = yes
					}
					#add 20% to ROOT influence
					set_temp_variable = { influence_add = influence_total } #from global rank idea
					multiply_temp_variable = { influence_add = 0.2 } #20%
					for_loop_effect = {
						end = influence_array^num
						value = v
						if = {
							limit = {
								check_variable = { influence_array^v = ROOT }
							}
							add_to_variable = { influence_array_val^v = influence_add }
						}
						#reduce all else by 30%
						else_if = {
							multiply_variable = { influence_array_val^v = 0.7 }
						}
					}
					hidden_effect = { recalculate_influence = yes }
					
					hidden_effect = {
						add_opinion_modifier = {
							target = ROOT
							modifier = succeded_coup
						}
						news_event = { id = News_influence.3 }
					}
				}
				#add event to country and world
				hidden_effect = {
					every_country = {
						limit = { is_ai = no }
						news_event = { days = 1 id = News_influence.4 }
					}
				}
			}
			#discovered
			33.3 = {
				modifier = {
					factor = var:FROM.fail_factor_biggest
				}
				
				custom_effect_tooltip = influence_coup_largest_discovered_TT
				
				FROM = {
					
					#remove a LOT of influence
					set_temp_variable = { influence_remove = influence_total } #from global rank idea
					multiply_temp_variable = { influence_remove = 0.1 } #10%
					for_loop_effect = {
						end = influence_array^num
						value = v
						if = {
							limit = {
								check_variable = { influence_array^v = ROOT }
							}
							subtract_from_variable = { influence_array_val^v = influence_remove }
							#half the remains
							multiply_variable = { influence_array_val^v = 0.5 }
						}
					}
					
					hidden_effect = { recalculate_influence = yes }
					
					hidden_effect = {
						add_opinion_modifier = {
							target = ROOT
							modifier = failed_coup
						}
					}
				}
				#add event to country and world
				hidden_effect = {
					every_country = {
						limit = { is_ai = no }
						news_event = { days = 1 id = News_influence.5 }
					}
				}
			}
			#civil_war
			33.3 = {
				modifier = {
					factor = var:FROM.civil_war_factor
				}
				
				FROM = {
					#kill player influence 
					for_loop_effect = {
						end = influence_array^num
						value = v
						if = {
							limit = {
								check_variable = { influence_array^v = ROOT }
							}
							set_variable = { current_influence = influence_array_val^v }
							remove_from_array = {
								array = influence_array
								index = v
							}
							remove_from_array = {
								array = influence_array_val
								index = v
							}
							remove_from_array = {
								array = influence_array_calc
								index = v
							}
						}
					}
					#damage relations with original gov
					hidden_effect = {
						add_opinion_modifier = {
							target = ROOT
							modifier = failed_coup
						}
					}
					recalculate_influence = yes
				}
				
				#democratic
				if = {
					limit = {
						has_government = democratic
					}
					FROM = {
						start_civil_war = {
							ideology = democratic
							size = 0.5
						}
						#first setup some things for original tag
						hidden_effect = {
							add_popularity = {
								ideology = democratic
								popularity = -0.5
							}
						}
						recalculate_party = yes
						update_majority_threshold = yes
						
					}	
					random_other_country = {
						limit = {
							original_tag = FROM
							has_government = democratic
						}
						
						start_politics_input = yes
						
						#new gov democratic
						if = {
							limit = { FROM = { has_country_flag = set_Communist-State } }
							set_country_flag = set_Communist-State
							add_to_array = { ruling_party = 0 }
							set_variable = { party_pop_array^0 = 0.7 }
						}
						else_if = {
							limit = { FROM = { has_country_flag = set_anarchist_communism } }
							set_country_flag = set_anarchist_communism
							add_to_array = { ruling_party = 1 }
							set_variable = { party_pop_array^1 = 0.7 }
						}
						else_if = {
							limit = { FROM = { has_country_flag = set_Conservative } }
							set_country_flag = set_Conservative
							add_to_array = { ruling_party = 2 }
							set_variable = { party_pop_array^2 = 0.7 }
						}
						else_if = {
							limit = { FROM = { has_country_flag = set_Autocracy } }
							set_country_flag = set_Autocracy
							add_to_array = { ruling_party = 3 }
							set_variable = { party_pop_array^3 = 0.7 }
						}
					
						#New TAG so need to set some generic politics
						set_popularities = {
							democratic = 70
							communism = 10
							neutrality = 10
							fascism = 0
							nationalist = 10
						}
						set_politics = {
							ruling_party = democratic
							elections_allowed = no
						}
						hidden_effect = {
							startup_politics = yes
							set_leader = yes		
							recalculate_party = yes
							hold_elections = yes
						}
						#influence transfer
						init_influence = yes
						set_variable = { domestic_influence_amount = FROM.current_influence }
						add_to_array = { influence_array = ROOT }
						add_to_array = { influence_array_val = FROM.current_influence }
						startup_influence = yes
					}
				}
				
				#communism
				if = {
					limit = {
						has_government = communism
					}
					FROM = {
						start_civil_war = {
							ideology = communism
							size = 0.5
						}
						#first setup some things for original tag
						hidden_effect = {
							add_popularity = {
								ideology = communism
								popularity = -0.5
							}
						}
						recalculate_party = yes
						update_majority_threshold = yes
						
					}	
					random_other_country = {
						limit = {
							original_tag = FROM
							has_government = communism
						}
						
						start_politics_input = yes
						
						#new gov communism
						if = {
							limit = { FROM = { has_country_flag = set_Communist-State } }
							set_country_flag = set_Communist-State
							add_to_array = { ruling_party = 4 }
							set_variable = { party_pop_array^4 = 0.7 }
						}
						else_if = {
							limit = { FROM = { has_country_flag = set_anarchist_communism } }
							set_country_flag = set_anarchist_communism
							add_to_array = { ruling_party = 5 }
							set_variable = { party_pop_array^5 = 0.7 }
						}
						else_if = {
							limit = { FROM = { has_country_flag = set_Conservative } }
							set_country_flag = set_Conservative
							add_to_array = { ruling_party = 6 }
							set_variable = { party_pop_array^6 = 0.7 }
						}
						else_if = {
							limit = { FROM = { has_country_flag = set_Autocracy } }
							set_country_flag = set_Autocracy
							add_to_array = { ruling_party = 7 }
							set_variable = { party_pop_array^7 = 0.7 }
						}
						else_if = {
							limit = { FROM = { has_country_flag = set_Mod_Vilayat_e_Faqih } }
							set_country_flag = set_Mod_Vilayat_e_Faqih
							add_to_array = { ruling_party = 8 }
							set_variable = { party_pop_array^8 = 0.7 }
						}
						else_if = {
							limit = { FROM = { has_country_flag = set_Vilayat_e_Faqih } }
							set_country_flag = set_Vilayat_e_Faqih
							add_to_array = { ruling_party = 9 }
							set_variable = { party_pop_array^9 = 0.7 }
						}
					
						#New TAG so need to set some generic politics
						set_popularities = {
							democratic = 10
							communism = 75
							neutrality = 5
							fascism = 0
							nationalist = 10
						}
						set_politics = {
							ruling_party = communism
							elections_allowed = no
						}
						hidden_effect = {
							startup_politics = yes
							set_leader = yes		
							recalculate_party = yes
							hold_elections = yes
						}
						#influence transfer
						init_influence = yes
						set_variable = { domestic_influence_amount = FROM.current_influence }
						add_to_array = { influence_array = ROOT }
						add_to_array = { influence_array_val = FROM.current_influence }
						startup_influence = yes
					}
				}
				
				#fascism
				if = {
					limit = {
						has_government = fascism
					}
					FROM = {
						start_civil_war = {
							ideology = fascism
							size = 0.5
						}
						#first setup some things for original tag
						hidden_effect = {
							add_popularity = {
								ideology = fascism
								popularity = -0.5
							}
						}
						recalculate_party = yes
						update_majority_threshold = yes
						
					}	
					random_other_country = {
						limit = {
							original_tag = FROM
							has_government = fascism
						}
						
						start_politics_input = yes
						
						#new gov fascism
						if = {
							limit = { FROM = { has_country_flag = set_Kingdom } }
							set_country_flag = set_Kingdom
							add_to_array = { ruling_party = 10 }
							set_variable = { party_pop_array^10 = 0.7 }
						}
						else_if = {
							limit = { FROM = { has_country_flag = set_Caliphate } }
							set_country_flag = set_Caliphate
							add_to_array = { ruling_party = 11 }
							set_variable = { party_pop_array^11 = 0.7 }
						}
					
						#New TAG so need to set some generic politics
						set_popularities = {
							democratic = 0
							communism = 5
							neutrality = 5
							fascism = 80
							nationalist = 10
						}
						set_politics = {
							ruling_party = fascism
							elections_allowed = no
						}
						hidden_effect = {
							startup_politics = yes
							set_leader = yes		
							recalculate_party = yes
							hold_elections = yes
						}
						#influence transfer
						init_influence = yes
						set_variable = { domestic_influence_amount = FROM.current_influence }
						add_to_array = { influence_array = ROOT }
						add_to_array = { influence_array_val = FROM.current_influence }
						startup_influence = yes
					}
				}
				
				#neutrality
				if = {
					limit = {
						has_government = neutrality
					}
					FROM = {
						start_civil_war = {
							ideology = neutrality
							size = 0.5
						}
						#first setup some things for original tag
						hidden_effect = {
							add_popularity = {
								ideology = neutrality
								popularity = -0.5
							}
						}
						recalculate_party = yes
						update_majority_threshold = yes
						
					}	
					random_other_country = {
						limit = {
							original_tag = FROM
							has_government = neutrality
						}
						
						start_politics_input = yes
						
						#new gov neutrality
						if = {
							limit = { FROM = { has_country_flag = set_Neutral_Muslim_Brotherhood } }
							set_country_flag = set_Neutral_Muslim_Brotherhood
							add_to_array = { ruling_party = 12 }
							set_variable = { party_pop_array^12 = 0.7 }
						}
						else_if = {
							limit = { FROM = { has_country_flag = set_Neutral_Autocracy } }
							set_country_flag = set_Neutral_Autocracy
							add_to_array = { ruling_party = 13 }
							set_variable = { party_pop_array^13 = 0.7 }
						}
						else_if = {
							limit = { FROM = { has_country_flag = set_Neutral_conservatism } }
							set_country_flag = set_Neutral_conservatism
							add_to_array = { ruling_party = 14 }
							set_variable = { party_pop_array^14 = 0.7 }
						}
						else_if = {
							limit = { FROM = { has_country_flag = set_oligarchism } }
							set_country_flag = set_oligarchism
							add_to_array = { ruling_party = 15 }
							set_variable = { party_pop_array^15 = 0.7 }
						}
						else_if = {
							limit = { FROM = { has_country_flag = set_Neutral_Libertarian } }
							set_country_flag = set_Neutral_Libertarian
							add_to_array = { ruling_party = 16 }
							set_variable = { party_pop_array^16 = 0.7 }
						}
						else_if = {
							limit = { FROM = { has_country_flag = set_Neutral_green } }
							set_country_flag = set_Neutral_green
							add_to_array = { ruling_party = 17 }
							set_variable = { party_pop_array^17 = 0.7 }
						}
						else_if = {
							limit = { FROM = { has_country_flag = set_neutral_Social } }
							set_country_flag = set_neutral_Social
							add_to_array = { ruling_party = 18 }
							set_variable = { party_pop_array^18 = 0.7 }
						}
						else_if = {
							limit = { FROM = { has_country_flag = set_Neutral_Communism } }
							set_country_flag = set_Neutral_Communism
							add_to_array = { ruling_party = 19 }
							set_variable = { party_pop_array^19 = 0.7 }
						}
					
						#New TAG so need to set some generic politics
						set_popularities = {
							democratic = 10
							communism = 10
							neutrality = 70
							fascism = 0
							nationalist = 10
						}
						set_politics = {
							ruling_party = neutrality
							elections_allowed = no
						}
						hidden_effect = {
							startup_politics = yes
							set_leader = yes		
							recalculate_party = yes
							hold_elections = yes
						}
						#influence transfer
						init_influence = yes
						set_variable = { domestic_influence_amount = FROM.current_influence }
						add_to_array = { influence_array = ROOT }
						add_to_array = { influence_array_val = FROM.current_influence }
						startup_influence = yes
					}
				}
				
				#nationalist civil war
				if = {
					limit = {
						has_government = nationalist
					}
					FROM = {
						start_civil_war = {
							ideology = nationalist
							size = 0.5
						}
						#first setup some things for original tag
						hidden_effect = {
							add_popularity = {
								ideology = nationalist
								popularity = -0.2
							}
						}
						recalculate_party = yes
						update_majority_threshold = yes
					}	
					random_other_country = {
						limit = {
							original_tag = FROM
							has_government = nationalist
						}
						
						start_politics_input = yes
						
						#new gov nationalist
						if = {
							limit = { FROM = { has_country_flag = set_Nat_Populism } }
							set_country_flag = set_Nat_Populism
							add_to_array = { ruling_party = 20 }
							set_variable = { party_pop_array^20 = 0.7 }
						}
						else_if = {
							limit = { FROM = { has_country_flag = set_Nat_Fascism } }
							set_country_flag = set_Nat_Fascism
							add_to_array = { ruling_party = 21 }
							set_variable = { party_pop_array^21 = 0.7 }
						}
						else_if = {
							limit = { FROM = { has_country_flag = set_Nat_Autocracy } }
							set_country_flag = set_Nat_Autocracy
							add_to_array = { ruling_party = 22 }
							set_variable = { party_pop_array^22 = 0.7 }
						}
						else_if = {
							limit = { FROM = { has_country_flag = set_Monarchist } }
							set_country_flag = set_Monarchist
							add_to_array = { ruling_party = 23 }
							set_variable = { party_pop_array^23 = 0.7 }
						}
					
						#New TAG so need to set some generic politics
						set_popularities = {
							democratic = 10
							communism = 10
							neutrality = 10
							fascism = 0
							nationalist = 70
						}
						set_politics = {
							ruling_party = nationalist
							elections_allowed = no
						}
						hidden_effect = {
							startup_politics = yes
							set_leader = yes		
							recalculate_party = yes
							hold_elections = yes
						}
						#influence transfer
						init_influence = yes
						set_variable = { domestic_influence_amount = FROM.current_influence }
						add_to_array = { influence_array = ROOT }
						add_to_array = { influence_array_val = FROM.current_influence }
						startup_influence = yes
					}
				}
				#add event to country and world
				hidden_effect = {
					every_country = {
						limit = { is_ai = no }
						news_event = { id = News_influence.6 }
					}
				}
			}
		}
	}
	
	#abort planning
	option = {
		name = influence.5.c
		log = "[GetDateText]: [This.GetName]: influence.5.c executed"
		FROM = { remove_set_ideology_flag = yes }
	}
}


news_event = {
	id = News_influence.3
	title = News_influence.3.t
	desc = News_influence.3.d
	picture = GFX_crime_fighting
	
	is_triggered_only = yes
	
	immediate = {
	}
	
	option = {
		name = News_influence.3.a
		log = "[GetDateText]: [This.GetName]: News_influence.3.a executed"
	}
}

news_event = {
	id = News_influence.4
	title = News_influence.4.t
	desc = News_influence.4.d
	picture = GFX_crime_fighting
	
	is_triggered_only = yes
	
	immediate = {
	}
	
	option = {
		name = News_influence.4.a
		log = "[GetDateText]: [This.GetName]: News_influence.4.a executed"
	}
}

news_event = {
	id = News_influence.5
	title = News_influence.5.t
	desc = News_influence.5.d
	picture = GFX_crime_fighting
	
	is_triggered_only = yes
	
	immediate = {
	}
	
	option = {
		name = News_influence.5.a
		log = "[GetDateText]: [This.GetName]: News_influence.5.a executed"
	}
}

news_event = {
	id = News_influence.6
	title = News_influence.6.t
	desc = News_influence.6.d
	picture = GFX_crime_fighting
	
	is_triggered_only = yes
	
	immediate = {
	}
	
	option = {
		name = News_influence.6.a
		log = "[GetDateText]: [This.GetName]: News_influence.6.a executed"
	}
}



### Bailout needed ###
country_event = {
	id = bankrupcy.0
	title = bankrupcy.0.t
	desc = bankrupcy.0.d
	picture = GFX_stock_market
	
	is_triggered_only = yes
	
	immediate = {
		set_country_flag = bailout_happened #prevent to trigger again even if not given - yet.
	}
	
	#Ask for help
	option = {
		name = bankrupcy.0.1
		log = "[GetDateText]: [This.GetName]: bankrupcy.0.1 executed"
		ai_chance = {
			factor = 10
			modifier = {
				factor = 5
				is_in_faction_with = influence_array^0
			}
			modifier = {
				factor = 0.1
				var:influence_array^0 = {
					has_opinion = {
						target = ROOT
						value < 1
					}
				}
			}
			modifier = {
				factor = 2
				var:influence_array^0 = {
					ic_ratio = { tag = PREV ratio > 10.0 } #has lotsa capacity
				}
			}
		}
		
		trigger = {
			has_variable = influence_array^0
			var:influence_array^0 = {
				ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
			}
			var:influence_array^0 = {
				has_opinion = {
					target = PREV
					value > -11
				}
			}
		}
		
		var:influence_array^0 = {
				country_event = { id = bankrupcy.1 days = 1 }
		}
	
	}
	option = {
		name = bankrupcy.0.2
		log = "[GetDateText]: [This.GetName]: bankrupcy.0.2 executed"
		ai_chance = {
			factor = 7
			modifier = {
				factor = 5
				is_in_faction_with = influence_array^1
			}
			modifier = {
				factor = 0.1
				var:influence_array^1 = {
					has_opinion = {
						target = ROOT
						value < 1
					}
				}
			}
			modifier = {
				factor = 2
				var:influence_array^1 = {
					ic_ratio = { tag = PREV ratio > 10.0 } #has lotsa capacity
				}
			}
		}
		
		trigger = {
			has_variable = influence_array^1
			var:influence_array^1 = {
				ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
			}
			var:influence_array^1 = {
				has_opinion = {
					target = PREV
					value > -11
				}
			}
		}
		
		var:influence_array^1 = {
				country_event = { id = bankrupcy.1 days = 1 }
		}
	
	}
	option = {
		name = bankrupcy.0.3
		log = "[GetDateText]: [This.GetName]: bankrupcy.0.3 executed"
		ai_chance = {
			factor = 5
			modifier = {
				factor = 5
				is_in_faction_with = influence_array^2
			}
			modifier = {
				factor = 0.1
				var:influence_array^2 = {
					has_opinion = {
						target = ROOT
						value < 1
					}
				}
			}
			modifier = {
				factor = 2
				var:influence_array^2 = {
					ic_ratio = { tag = PREV ratio > 10.0 } #has lotsa capacity
				}
			}
		}
		
		trigger = {
			has_variable = influence_array^2
			var:influence_array^2 = {
				ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
			}
			var:influence_array^2 = {
				has_opinion = {
					target = PREV
					value > -11
				}
			}
		}
		
		var:influence_array^2 = {
				country_event = { id = bankrupcy.1 days = 1 }
		}
	
	}
	
	option = {
		name = bankrupcy.0.4
		log = "[GetDateText]: [This.GetName]: bankrupcy.0.4 executed"
		ai_chance = {
			factor = 3
			modifier = {
				factor = 3
				is_in_faction_with = var:influence_array^3
			}
			modifier = {
				factor = 0.1
				var:influence_array^3 = {
					has_opinion = {
						target = ROOT
						value < 1
					}
				}
			}
			modifier = {
				factor = 2
				var:influence_array^3 = {
					ic_ratio = { tag = PREV ratio > 10.0 } #has lotsa capacity
				}
			}
		}
		
		trigger = {
			has_variable = influence_array^3
			var:influence_array^3 = {
				ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
			}
			var:influence_array^3 = {
				has_opinion = {
					target = PREV
					value > -11
				}
			}
			#only if previous could not
			NOT = {
				count_triggers = { 
					amount = 3
					AND = {
						has_variable = influence_array^0
						var:influence_array^0 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^0 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^1
						var:influence_array^1 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^1 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^2
						var:influence_array^2 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^2 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}	
				}
			}
		}
		
		var:influence_array^3 = {
				country_event = { id = bankrupcy.1 days = 1 }
		}
	
	}
	
	option = {
		name = bankrupcy.0.5
		log = "[GetDateText]: [This.GetName]: bankrupcy.0.5 executed"
		ai_chance = {
			factor = 2
			modifier = {
				factor = 3
				is_in_faction_with = var:influence_array^4
			}
			modifier = {
				factor = 0.1
				var:influence_array^4 = {
					has_opinion = {
						target = ROOT
						value < 1
					}
				}
			}
			modifier = {
				factor = 2
				var:influence_array^4 = {
					ic_ratio = { tag = PREV ratio > 10.0 } #has lotsa capacity
				}
			}
		}
		
		trigger = {
			has_variable = influence_array^4
			var:influence_array^4 = {
				ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
			}
			var:influence_array^4 = {
				has_opinion = {
					target = PREV
					value > -11
				}
			}
			#only if previous could not
			NOT = {
				count_triggers = {
					amount = 3
					AND = {
						has_variable = influence_array^0
						var:influence_array^0 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^0 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^1
						var:influence_array^1 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^1 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^2
						var:influence_array^2 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^2 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^3
						var:influence_array^3 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^3 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}					
				}
			}
		}
		
		var:influence_array^4 = {
				country_event = { id = bankrupcy.1 days = 1 }
		}
	
	}
	
	option = {
		name = bankrupcy.0.6
		log = "[GetDateText]: [This.GetName]: bankrupcy.0.6 executed"
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				is_in_faction_with = influence_array^5.id
			}
			modifier = {
				factor = 0.1
				var:influence_array^5 = {
					has_opinion = {
						target = ROOT
						value < 1
					}
				}
			}
			modifier = {
				factor = 2
				var:influence_array^5 = {
					ic_ratio = { tag = PREV ratio > 10.0 } #has lotsa capacity
				}
			}
		}
		
		trigger = {
			has_variable = influence_array^5
			var:influence_array^5 = {
				ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
			}
			var:influence_array^5 = {
				has_opinion = {
					target = PREV
					value > -11
				}
			}
			#only if previous could not
			NOT = {
				count_triggers = {
					amount = 3
					AND = {
						has_variable = influence_array^0
						var:influence_array^0 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^0 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^1
						var:influence_array^1 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^1 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^2
						var:influence_array^2 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^2 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^3
						var:influence_array^3 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^3 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^4
						var:influence_array^4 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^4 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}					
				}
			}
		}
		
		var:influence_array^5 = {
				country_event = { id = bankrupcy.1 days = 1 }
		}
	
	}
	
	option = {
		name = bankrupcy.0.7
		log = "[GetDateText]: [This.GetName]: bankrupcy.0.7 executed"
		ai_chance = {
			factor = 0.5
			modifier = {
				factor = 3
				is_in_faction_with = influence_array^6.id
			}
			modifier = {
				factor = 0.1
				var:influence_array^6 = {
					has_opinion = {
						target = ROOT
						value < 1
					}
				}
			}
			modifier = {
				factor = 2
				var:influence_array^6 = {
					ic_ratio = { tag = PREV ratio > 10.0 } #has lotsa capacity
				}
			}
		}
		
		trigger = {
			has_variable = influence_array^6
			var:influence_array^6 = {
				ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
			}
			var:influence_array^6 = {
				has_opinion = {
					target = PREV
					value > -11
				}
			}
			#only if previous could not
			NOT = {
				count_triggers = {
					amount = 3
					AND = {
						has_variable = influence_array^0
						var:influence_array^0 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^0 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^1
						var:influence_array^1 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^1 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^2
						var:influence_array^2 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^2 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^3
						var:influence_array^3 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^3 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^4
						var:influence_array^4 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^4 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^5
						var:influence_array^5 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^5 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}					
				}
			}
		}
		
		var:influence_array^6 = {
				country_event = { id = bankrupcy.1 days = 1 }
		}
	
	}
	
	#We don't need no help, thank you
	option = {
		name = bankrupcy.0.b
		log = "[GetDateText]: [This.GetName]: bankrupcy.0.b executed"
		ai_chance = { factor = 0 }
		trigger = {
			OR = {
				AND = {
					has_variable = influence_array^0
					var:influence_array^0 = {
						ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
					}
					var:influence_array^0 = {
						has_opinion = {
							target = PREV
							value > -11
						}
					}
				}
				AND = {
					has_variable = influence_array^1
					var:influence_array^1 = {
						ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
					}
					var:influence_array^1 = {
						has_opinion = {
							target = PREV
							value > -11
						}
					}
				}
				AND = {
					has_variable = influence_array^2
					var:influence_array^2 = {
						ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
					}
					var:influence_array^2 = {
						has_opinion = {
							target = PREV
							value > -11
						}
					}
				}
				AND = {
					has_variable = influence_array^3
					var:influence_array^3 = {
						ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
					}
					var:influence_array^3 = {
						has_opinion = {
							target = PREV
							value > -11
						}
					}
				}
				AND = {
					has_variable = influence_array^4
					var:influence_array^4 = {
						ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
					}
					var:influence_array^4 = {
						has_opinion = {
							target = PREV
							value > -11
						}
					}
				}
				AND = {
					has_variable = influence_array^5
					var:influence_array^5 = {
						ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
					}
					var:influence_array^5 = {
						has_opinion = {
							target = PREV
							value > -11
						}
					}
				}
				AND = {
					has_variable = influence_array^6
					var:influence_array^6 = {
						ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
					}
					var:influence_array^6 = {
						has_opinion = {
							target = PREV
							value > -11
						}
					}
				}
			}
		}
	}
	#we don't have anyone we can ask
	option = {
		name = bankrupcy.0.c
		log = "[GetDateText]: [This.GetName]: bankrupcy.0.c executed"
		ai_chance = { factor = 0 }
		trigger = {
			NOT = {
				OR = {
					AND = {
						has_variable = influence_array^0
						var:influence_array^0 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^0 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^1
						var:influence_array^1 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^1 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^2
						var:influence_array^2 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^2 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^3
						var:influence_array^3 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^3 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^4
						var:influence_array^4 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^4 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^5
						var:influence_array^5 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^5 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
					AND = {
						has_variable = influence_array^6
						var:influence_array^6 = {
							ic_ratio = { tag = PREV ratio > 2.0 } #has capacity
						}
						var:influence_array^6 = {
							has_opinion = {
								target = PREV
								value > -11
							}
						}
					}
				}
			}
		}
	}
}

### Bailout Requested ###
country_event = {
	id = bankrupcy.1
	title = bankrupcy.1.t
	desc = bankrupcy.1.d
	picture = GFX_stock_market
	
	is_triggered_only = yes
	
	immediate = {
		#10% of debt
		set_variable = { bailout_sum = FROM.debt }
		multiply_variable = { bailout_sum = 0.1 }
	}
	
	#Give it
	option = {
		name = bankrupcy.1.a
		log = "[GetDateText]: [This.GetName]: bankrupcy.1.1 executed"
		ai_chance = {
			factor = 10
		}
		custom_effect_tooltip = bankrupcy_bailout_sum_TT
		subtract_from_variable = { treasury = bailout_sum }
		custom_effect_tooltip = bankrupcy_bailout_influence_TT
		FROM = { news_event = { id = News_bankrupcy.2 days = 1 } }
	}
	#We have no help to offer
	option = {
		name = bankrupcy.1.b
		log = "[GetDateText]: [This.GetName]: bankrupcy.0.b executed"
		ai_chance = { factor = 0 }
	}
}

### we got the bailout
news_event = {
	id = News_bankrupcy.2
	title = News_bankrupcy.2.t
	desc = News_bankrupcy.2.d
	#picture = GFX_stock_market
	
	is_triggered_only = yes
	
	immediate = {
		set_country_flag = bailout_given
		startup_extra_setup = yes #safety reboot
	}
	
	#yeah...
	option = {
		name = News_bankrupcy.2.a
		log = "[GetDateText]: [This.GetName]: News_bankrupcy.2.a executed"
		custom_effect_tooltip = interest_rate_reduced_10_TT
		give_military_access = FROM
		multiply_variable = { domestic_influence_amount = 0.33 }
		if = { limit = { check_variable = { influence_array^0 = FROM } }
			multiply_variable = { influence_array_val^0 = 3 }
		}
		else_if = { limit = { check_variable = { influence_array^1 = FROM } }
			multiply_variable = { influence_array_val^1 = 3 }
		}
		else_if = { limit = { check_variable = { influence_array^2 = FROM } }
			multiply_variable = { influence_array_val^2 = 3 }
		}
		else_if = { limit = { check_variable = { influence_array^3 = FROM } }
			multiply_variable = { influence_array_val^3 = 3 }
		}
		else_if = { limit = { check_variable = { influence_array^4 = FROM } }
			multiply_variable = { influence_array_val^4 = 3 }
		}
		else_if = { limit = { check_variable = { influence_array^5 = FROM } }
			multiply_variable = { influence_array_val^5 = 3 }
		}
		else_if = { limit = { check_variable = { influence_array^6 = FROM } }
			multiply_variable = { influence_array_val^6 = 3 }
		}
		recalculate_influence = yes
	}
}

### OOOPS BANKRUPT!! ###
news_event = {
	id = News_bankrupcy.6
	title = News_bankrupcy.6.t
	desc = News_bankrupcy.6.d
	#picture = GFX_stock_market
	
	is_triggered_only = yes
	
	immediate = {
		add_timed_idea = { idea = bankrupcy days = 1825 } #5-years
		
		custom_effect_tooltip = econvent.list.depression_tt
		set_country_flag = disable_cycle_costs
		hidden_effect = { add_ideas = depression }
		clr_country_flag = disable_cycle_costs
		
		#sells reserves
		subtract_from_variable = { debt = int_investments }
		set_variable = { int_investments = 0 }
		multiply_variable = { debt = 0.2 } #reduces debt
		
		set_variable = { reduction_factor = 0.25 }
		remove_civilian_industry_effect = yes
		
		clear_variable = reduction_factor
		
		startup_extra_setup = yes #safety reboot
		
		#init_influence = yes
	set_variable = { domestic_influence_amount = 0 }
		recalculate_influence = yes
	}
	
	#Give it
	option = {
		name = News_bankrupcy.6.a
		log = "[GetDateText]: [This.GetName]: News_bankrupcy.6.a executed"
		
	}
}

### Central Bank warns of housing bubble & possible crisis ###
country_event = {
	id = econvent.1
	title = econvent.1.t
	desc = econvent.1.d
	
	
	trigger = {
		NOT = { has_idea = depression }
		NOT = { has_idea = recession } 
		NOT = { has_idea = stagnation }
		NOT = { has_country_flag = possible_housing_bubble }
		NOT = { has_country_flag = housing_crash }
	}
	
	mean_time_to_happen = {
		days = 3000
		modifier = {
			factor = 0.6
			has_idea = economic_boom
		}
		modifier = {
			factor = 0.8
			has_idea = fast_growth
		}
	}
	
	#Take steps to avoid crisis
	option = {
		name = econvent.1.a
		log = "[GetDateText]: [This.GetName]: econvent.1.a executed"
		ai_chance = { factor = 100 }
		trigger = { has_idea = economic_boom }
		custom_effect_tooltip = econvent.1.a1_tt 
		set_country_flag = disable_cycle_costs
		hidden_effect = { add_ideas = fast_growth }
		clr_country_flag = disable_cycle_costs
	
	}
	option = {
		name = econvent.1.a
		log = "[GetDateText]: [This.GetName]: econvent.1.a executed"
		ai_chance = { factor = 100 }
		trigger = { has_idea = fast_growth }
		custom_effect_tooltip = econvent.1.a2_tt
		set_country_flag = disable_cycle_costs
		hidden_effect = { add_ideas = stable_growth }
		clr_country_flag = disable_cycle_costs
			
	}
	option = {
		name = econvent.1.a
		log = "[GetDateText]: [This.GetName]: econvent.1.a executed"
		ai_chance = { factor = 100 }
		trigger = { has_idea = stable_growth }
		custom_effect_tooltip = econvent.1.a3_tt 
		set_country_flag = disable_cycle_costs
		hidden_effect = { add_ideas = stagnation }
		clr_country_flag = disable_cycle_costs
			
	}
	#Crisis?! What crisis!?
	option = {
		name = econvent.1.b
		log = "[GetDateText]: [This.GetName]: econvent.1.b executed"
		ai_chance = { factor = 0 }
		custom_effect_tooltip = econvent.1.b_tt 
		set_country_flag = possible_housing_bubble
	}
}


	

#### Collapsing housing prices ####
country_event = {
	id = econvent.2
	title = econvent.2.t
	desc = econvent.2.d
	
	trigger = {
		has_country_flag = possible_housing_bubble
		NOT = { has_idea = depression }
		NOT = { has_idea = recession } 
		NOT = { has_idea = stagnation }
	}
	
	mean_time_to_happen = {
		days = 1830
		modifier = {
			factor = 0.6
			has_idea = economic_boom
		}
		modifier = {
			factor = 0.8
			has_idea = fast_growth
		}
		modifier = {
			factor = 0.5
			has_country_flag = consumption_slowdown
		}
	}
	
	immediate = {
		set_country_flag = {
			flag = housing_crash
			value = 1
		}
		clr_country_flag = possible_housing_bubble
	}
	
	#Lower interest-rates and demand banks increase lending 
	option = {
		name = econvent.2.a
		log = "[GetDateText]: [This.GetName]: econvent.2.a executed"
		ai_chance = { factor = 0 }
		trigger = { has_idea = economic_boom }
		set_country_flag = {
			 flag = voodoo_economics
			 value = 1
		 }
			hidden_effect = { country_event = { id = econvent_remove_flag.2 days = 365 } } #clears voodoo_economics flag
			hidden_effect = { country_event = { id = econvent_remove_flag.1 days = 365 } } #clears housing_crash flag
			#add_timed_idea = { idea = voodoo_economics days = 1 } ## Need to make
			custom_effect_tooltip = econvent.from_booming_tt
		random_list = {
			70 = {
				custom_effect_tooltip = econvent.list.fast_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = fast_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			20 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			10 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
		}
		custom_effect_tooltip = econvent.voodoo_economics_tt
	}
	option = {
		name = econvent.2.a
		log = "[GetDateText]: [This.GetName]: econvent.2.a executed"
		ai_chance = { factor = 0 }
		trigger = { has_idea = fast_growth }
		set_country_flag = { #just flag for now
			 flag = voodoo_economics
			 value = 1
		 }
			hidden_effect = {  country_event = { id = econvent_remove_flag.2 days = 365 } } #clears voodoo_economics flag
			hidden_effect = { country_event = { id = econvent_remove_flag.1 days = 365 } } #clears housing_crash flag
			#add_timed_idea = { idea = voodoo_economics days = 1 } ## Need to make
			custom_effect_tooltip = econvent.from_fast_growth_tt
		random_list = {
			70 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			20 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
			10 = {
				custom_effect_tooltip = econvent.list.recession_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = recession }
				clr_country_flag = disable_cycle_costs
				
			}
		}
		custom_effect_tooltip = econvent.voodoo_economics_tt
	}
	option = {
		name = econvent.2.a
		log = "[GetDateText]: [This.GetName]: econvent.2.a executed"
		ai_chance = { factor = 0 }
		trigger = { has_idea = stable_growth }
		set_country_flag = { #just flag for now
			 flag = voodoo_economics
			 value = 1
		 }
			hidden_effect = {  country_event = { id = econvent_remove_flag.2 days = 365 } } #clears voodoo_economics flag
			hidden_effect = { country_event = { id = econvent_remove_flag.1 days = 365 } } #clears housing_crash flag
			#add_timed_idea = { idea = voodoo_economics days = 1 } ## Need to make
			custom_effect_tooltip = econvent.from_stable_growth_tt
		random_list = {
			80 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
			20 = {
				custom_effect_tooltip = econvent.list.recession_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = recession }
				clr_country_flag = disable_cycle_costs
				
			}
		}
		custom_effect_tooltip = econvent.voodoo_economics_tt
	}
	option = {
		name = econvent.2.a
		log = "[GetDateText]: [This.GetName]: econvent.2.a executed"
		ai_chance = { factor = 0 }
		trigger = { has_idea = stagnation }
		set_country_flag = { #just flag for now
			 flag = voodoo_economics
			 value = 1
		 }
			hidden_effect = {  country_event = { id = econvent_remove_flag.2 days = 365 } } #clears voodoo_economics flag
			hidden_effect = { country_event = { id = econvent_remove_flag.1 days = 1365 } } #clears housing_crash flag
			#add_timed_idea = { idea = voodoo_economics days = 1 } ## Need to make
			custom_effect_tooltip = econvent.from_stagnation_tt
		random_list = {
			50 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			50 = {
				custom_effect_tooltip = econvent.list.recession_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = recession }
				clr_country_flag = disable_cycle_costs
				
			}
		}
		custom_effect_tooltip = econvent.voodoo_economics_tt
	}
	option = {
		name = econvent.2.a
		log = "[GetDateText]: [This.GetName]: econvent.2.a executed"
		ai_chance = { factor = 0 }
		trigger = { has_idea = recession }
		set_country_flag = { #just flag for now
			 flag = voodoo_economics
			 value = 1
		 }
			hidden_effect = {  country_event = { id = econvent_remove_flag.2 days = 365 } } #clears voodoo_economics flag
			hidden_effect = { country_event = { id = econvent_remove_flag.1 days = 365 } } #clears housing_crash flag
			#add_timed_idea = { idea = voodoo_economics days = 1 } ## Need to make
			custom_effect_tooltip = econvent.from_recession_tt
			random_list = {
			60 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			40 = {
				custom_effect_tooltip = econvent.list.depression_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = depression }
				clr_country_flag = disable_cycle_costs
				
			}
		}
		custom_effect_tooltip = econvent.voodoo_economics_tt
	}
			
	#This adjustment is painful, but nessesary
	#Crash Effects
	option = {
		name = econvent.2.b
		log = "[GetDateText]: [This.GetName]: econvent.2.b executed"
		ai_chance = { factor = 100 }
		trigger = { has_idea = economic_boom }
		modify_country_flag = {
			 flag = housing_crash
			 value = 1
		 }
		hidden_effect = { country_event = { id = econvent_remove_flag.1 days = 245 } } #clears housing_crash flag
		custom_effect_tooltip = econvent.from_booming_tt
		random_list = {
			65 = {
				custom_effect_tooltip = econvent.list.fast_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = fast_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			20 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			15 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
			
		}
		custom_effect_tooltip = econvent.2.b_tt
	}
	option = {
		name = econvent.2.b
		log = "[GetDateText]: [This.GetName]: econvent.2.b executed"
		trigger = { has_idea = fast_growth }
		ai_chance = { factor = 100 }
		modify_country_flag = {
			 flag = housing_crash
			 value = 1
		 }
		hidden_effect = { country_event = { id = econvent_remove_flag.1 days = 245 } } #clears housing_crash flag
		custom_effect_tooltip = econvent.from_fast_growth_tt
		random_list = {
			65 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			35 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
		}
		custom_effect_tooltip = econvent.2.b_tt
	}
	option = {
		name = econvent.2.b
		log = "[GetDateText]: [This.GetName]: econvent.2.b executed"
		ai_chance = { factor = 100 }
		trigger = { has_idea = stable_growth }
		modify_country_flag = {
			 flag = housing_crash
			 value = 1
		 }
		hidden_effect = { country_event = { id = econvent_remove_flag.1 days = 245 } } #clears housing_crash flag
		custom_effect_tooltip = econvent.from_stable_growth_tt
		random_list = {
			65 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
			35 = {
			custom_effect_tooltip = econvent.list.recession_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = recession }
				clr_country_flag = disable_cycle_costs
				
			}
		}
		custom_effect_tooltip = econvent.2.b_tt
	}
	option = {
		name = econvent.2.b
		log = "[GetDateText]: [This.GetName]: econvent.2.b executed"
		ai_chance = { factor = 100 }
		trigger = { has_idea = stagnation }
		modify_country_flag = {
			 flag = housing_crash
			 value = 1
		 }
		hidden_effect = { country_event = { id = econvent_remove_flag.1 days = 245 } } #clears housing_crash flag
		custom_effect_tooltip = econvent.from_stagnation_tt
		random_list = {
			90 = {
				custom_effect_tooltip = econvent.list.recession_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = recession }
				clr_country_flag = disable_cycle_costs
				
			}
			10 = {
				custom_effect_tooltip = econvent.list.depression_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = depression }
				clr_country_flag = disable_cycle_costs
				
			}
		}
		custom_effect_tooltip = econvent.2.b_tt
	}
	option = {
		name = econvent.2.b
		log = "[GetDateText]: [This.GetName]: econvent.2.b executed"
		ai_chance = { factor = 100 }
		trigger = { has_idea = recession }
		modify_country_flag = {
			 flag = housing_crash
			 value = 1
		 }
		hidden_effect = { country_event = { id = econvent_remove_flag.1 days = 245 } } #clears housing_crash flag
		custom_effect_tooltip = econvent.from_recession2_tt
		custom_effect_tooltip = econvent.list.depression_tt
		set_country_flag = disable_cycle_costs
		hidden_effect = { add_ideas = depression }
		clr_country_flag = disable_cycle_costs
		custom_effect_tooltip = econvent.2.b_tt
		
		}
}

### Stock Market Crash
country_event = {
	id = econvent.3
	title = econvent.3.t
	desc = econvent.3.d
	
	trigger = {
		has_country_flag = housing_crash
		NOT = { has_idea = depression }
		NOT = { has_idea = recession } 
	}
	
	mean_time_to_happen = {
		days = 1800
		modifier = {
			factor = 0.4
			has_idea = economic_boom
		}
		modifier = {
			factor = 0.7
			has_idea = fast_growth
		}
		modifier = {
			factor = 0.5
			has_country_flag = voodoo_economics
		}
		modifier = {
			factor = 0.5
			has_country_flag = consumption_slowdown
		}
	}
	
	immediate = {
		set_country_flag = {
			 flag = stock_market_crash
			 value = 1
		 }
	}
	
	#Crash Effects
	option = {
		name = econvent.3.a
		log = "[GetDateText]: [This.GetName]: econvent.3.a executed"
		trigger = { has_idea = economic_boom }
		custom_effect_tooltip = econvent.from_booming_tt
		hidden_effect = { country_event = { id = econvent_remove_flag.3 days = 365 } } #clears stock_market_crash flag
		random_list = {
			70 = {
				custom_effect_tooltip = econvent.list.fast_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = fast_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			30 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.3.a
		log = "[GetDateText]: [This.GetName]: econvent.3.a executed"
		trigger = { has_idea = fast_growth }
		custom_effect_tooltip = econvent.from_fast_growth_tt
		hidden_effect = { country_event = { id = econvent_remove_flag.3 days = 365 } } #clears stock_market_crash flag
		random_list = {
			75 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			25 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.3.a
		log = "[GetDateText]: [This.GetName]: econvent.3.a executed"
		trigger = { has_idea = stable_growth }
		custom_effect_tooltip = econvent.from_stable_growth_tt
		hidden_effect = { country_event = { id = econvent_remove_flag.3 days = 365 } } #clears stock_market_crash flag
		random_list = {
			80 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
			20 = {
				custom_effect_tooltip = econvent.list.recession_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = recession }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.3.a
		log = "[GetDateText]: [This.GetName]: econvent.3.a executed"
		trigger = { has_idea = stagnation }
		custom_effect_tooltip = econvent.from_stagnation_tt
		hidden_effect = { country_event = { id = econvent_remove_flag.3 days = 365 } } #clears stock_market_crash flag
		random_list = {
			90 = {
				custom_effect_tooltip = econvent.list.recession_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = recession }
				clr_country_flag = disable_cycle_costs
				
			}
			10 = {
				custom_effect_tooltip = econvent.list.depression_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = depression }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.3.a
		log = "[GetDateText]: [This.GetName]: econvent.3.a executed"
		trigger = { has_idea = recession }
		hidden_effect = { country_event = { id = econvent_remove_flag.3 days = 365 } } #clears stock_market_crash flag
		custom_effect_tooltip = econvent.from_recession2_tt
		custom_effect_tooltip = econvent.list.depression_tt
		set_country_flag = disable_cycle_costs
		hidden_effect = { add_ideas = depression }
		clr_country_flag = disable_cycle_costs
		
		}
}

### Bank Crisis
country_event = {
	id = econvent.4
	title = econvent.4.t
	desc = econvent.4.d
	
	trigger = {
		has_country_flag = housing_crash
		has_country_flag = stock_market_crash
		NOT = { has_idea = depression }
		NOT = { has_idea = recession } 
	}
	
	mean_time_to_happen = {
		days = 2000
		modifier = {
			factor = 0.3
			has_idea = economic_boom
		}
		modifier = {
			factor = 0.6
			has_idea = fast_growth
		}
		modifier = {
			factor = 0.5
			has_country_flag = voodoo_economics
		}
		modifier = {
			factor = 0.5
			has_country_flag = consumption_slowdown
		}
	}
	
	immediate = {
		set_country_flag = {
			flag = bank_crisis
			value = 1
		}
	}
	
	#Bail them out!
	option = {
		name = econvent.4.a
		log = "[GetDateText]: [This.GetName]: econvent.4.a executed"
		trigger = { has_idea = economic_boom }
		hidden_effect = { country_event = { id = econvent_remove_flag.4 days = 365 } } #clears bank_crisis flag
		#increase_debtcount_by_12 = yes
		#custom_effect_tooltip = econvent.debt_10p_tt
		custom_effect_tooltip = econvent.from_booming_tt
		random_list = {
			60 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			40 = {
				custom_effect_tooltip = econvent.list.fast_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = fast_growth }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.4.a
		log = "[GetDateText]: [This.GetName]: econvent.4.a executed"
		trigger = { has_idea = fast_growth }
		hidden_effect = { country_event = { id = econvent_remove_flag.4 days = 365 } } #clears bank_crisis flag
		#increase_debtcount_by_12 = yes
		#custom_effect_tooltip = econvent.debt_10p_tt
		custom_effect_tooltip = econvent.from_fast_growth_tt
		random_list = {
			60 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			40 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.4.a
		log = "[GetDateText]: [This.GetName]: econvent.4.a executed"
		trigger = { has_idea = stable_growth }
		hidden_effect = { country_event = { id = econvent_remove_flag.4 days = 365 } } #clears bank_crisis flag
		#increase_debtcount_by_12 = yes
		#custom_effect_tooltip = econvent.debt_10p_tt
		custom_effect_tooltip = econvent.from_stable_growth_tt
		random_list = {
			70 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			30 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.4.a
		log = "[GetDateText]: [This.GetName]: econvent.4.a executed"
		trigger = { has_idea = stagnation }
		hidden_effect = { country_event = { id = econvent_remove_flag.4 days = 365 } } #clears bank_crisis flag
		#increase_debtcount_by_12 = yes
		#custom_effect_tooltip = econvent.debt_10p_tt
		custom_effect_tooltip = econvent.from_stagnation_tt
		random_list = {
			80 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			20 = {
				custom_effect_tooltip = econvent.list.recession_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = recession }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.4.a
		log = "[GetDateText]: [This.GetName]: econvent.4.a executed"
		trigger = { has_idea = recession }
		hidden_effect = { country_event = { id = econvent_remove_flag.4 days = 365 } } #clears bank_crisis flag
		#increase_debtcount_by_12 = yes
		#custom_effect_tooltip = econvent.debt_10p_tt
		custom_effect_tooltip = econvent.from_recession_tt
		random_list = {
			90 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			10 = {
				custom_effect_tooltip = econvent.list.depression_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = depression }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	
	#Avoid bailouts, but help savers if banks go bankrupt
	option = {
		name = econvent.4.b
		log = "[GetDateText]: [This.GetName]: econvent.4.b executed"
		trigger = { has_idea = economic_boom }
		#increase_debtcount_by_6 = yes
		#custom_effect_tooltip = econvent.debt_5p_tt
		modify_country_flag = {
			 flag = bank_crisis
			 value = 1
		 }
		hidden_effect = { country_event = { id = econvent_remove_flag.4 days = 305 } } #clears bank_crisis flag
		custom_effect_tooltip = econvent.from_booming_tt
		random_list = {
			80 = {
				custom_effect_tooltip = econvent.list.fast_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = fast_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			20 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.4.b
		log = "[GetDateText]: [This.GetName]: econvent.4.b executed"
		trigger = { has_idea = fast_growth }
		#increase_debtcount_by_6 = yes
		#custom_effect_tooltip = econvent.debt_5p_tt
		modify_country_flag = {
			 flag = bank_crisis
			 value = 1
		 }
		hidden_effect = { country_event = { id = econvent_remove_flag.4 days = 305 } } #clears bank_crisis flag
		custom_effect_tooltip = econvent.from_fast_growth_tt
		random_list = {
			85 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			15 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.4.b
		log = "[GetDateText]: [This.GetName]: econvent.4.b executed"
		trigger = { has_idea = stable_growth }
		#increase_debtcount_by_6 = yes
		#custom_effect_tooltip = econvent.debt_5p_tt
		modify_country_flag = {
			 flag = bank_crisis
			 value = 1
		 }
		hidden_effect = { country_event = { id = econvent_remove_flag.4 days = 305 } } #clears bank_crisis flag
		custom_effect_tooltip = econvent.from_stable_growth_tt
		random_list = {
			90 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
			10 = {
				custom_effect_tooltip = econvent.list.recession_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = recession }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.4.b
		log = "[GetDateText]: [This.GetName]: econvent.4.b executed"
		trigger = { has_idea = stagnation }
		#increase_debtcount_by_6 = yes
		#custom_effect_tooltip = econvent.debt_5p_tt
		modify_country_flag = {
			 flag = bank_crisis
			 value = 1
		 }
		hidden_effect = { country_event = { id = econvent_remove_flag.4 days = 305 } } #clears bank_crisis flag
		custom_effect_tooltip = econvent.from_stagnation_tt
		random_list = {
			20 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			70 = {
				custom_effect_tooltip = econvent.list.recession_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = recession }
				clr_country_flag = disable_cycle_costs
				
			}
			10 = {
				custom_effect_tooltip = econvent.list.depression_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = depression }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.4.b
		log = "[GetDateText]: [This.GetName]: econvent.4.b executed"
		trigger = { has_idea = recession }
		#increase_debtcount_by_6 = yes
		#custom_effect_tooltip = econvent.debt_5p_tt
		modify_country_flag = {
			 flag = bank_crisis
			 value = 1
		 }
		hidden_effect = { country_event = { id = econvent_remove_flag.4 days = 305 } } #clears bank_crisis flag
		custom_effect_tooltip = econvent.from_recession_tt
		random_list = {
			30 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			70 = {
				custom_effect_tooltip = econvent.list.depression_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = depression }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	
	#Survival of the fittest is what makes capitalism beautiful
	option = {
		name = econvent.4.c
		log = "[GetDateText]: [This.GetName]: econvent.4.c executed"
		trigger = { has_idea = economic_boom }
		modify_country_flag = {
			 flag = bank_crisis
			 value = 1
		 }
		hidden_effect = { country_event = { id = econvent_remove_flag.4 days = 245 } } #clears bank_crisis flag
		custom_effect_tooltip = econvent.from_booming_tt
		random_list = {
			60 = {
				custom_effect_tooltip = econvent.list.fast_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = fast_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			40 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.4.c
		log = "[GetDateText]: [This.GetName]: econvent.4.c executed"
		trigger = { has_idea = fast_growth }
		modify_country_flag = {
			 flag = bank_crisis
			 value = 1
		 }
		hidden_effect = { country_event = { id = econvent_remove_flag.4 days = 245 } } #clears bank_crisis flag
		custom_effect_tooltip = econvent.from_fast_growth_tt
		random_list = {
			65 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			35 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.4.c
		log = "[GetDateText]: [This.GetName]: econvent.4.c executed"
		trigger = { has_idea = stable_growth }
		modify_country_flag = {
			 flag = bank_crisis
			 value = 1
		 }
		hidden_effect = { country_event = { id = econvent_remove_flag.4 days = 245 } } #clears bank_crisis flag
		custom_effect_tooltip = econvent.from_stable_growth_tt
		random_list = {
			70 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
			30 = {
				custom_effect_tooltip = econvent.list.recession_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = recession }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.4.c
		log = "[GetDateText]: [This.GetName]: econvent.4.c executed"
		trigger = { has_idea = stagnation }
		modify_country_flag = {
			 flag = bank_crisis
			 value = 1
		 }
		hidden_effect = { country_event = { id = econvent_remove_flag.4 days = 245 } } #clears bank_crisis flag
		custom_effect_tooltip = econvent.from_stagnation_tt
		random_list = {
			80 = {
				custom_effect_tooltip = econvent.list.recession_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = recession }
				clr_country_flag = disable_cycle_costs
				
			}
			20 = {
				custom_effect_tooltip = econvent.list.depression_tt	
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = depression }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.4.c
		log = "[GetDateText]: [This.GetName]: econvent.4.c executed"
		trigger = { has_idea = recession }
		modify_country_flag = {
			 flag = bank_crisis
			 value = 1
		 }
		hidden_effect = { country_event = { id = econvent_remove_flag.4 days = 245 } } #clears bank_crisis flag
		custom_effect_tooltip = econvent.from_recession2_tt
		custom_effect_tooltip = econvent.list.depression_tt
		set_country_flag = disable_cycle_costs
		hidden_effect = { add_ideas = depression }
		clr_country_flag = disable_cycle_costs
		
	}
}


### Slowdown in consumption as pessimism and unemployment on the rise ###

country_event = {
	id = econvent.5
	title = econvent.5.t
	desc = econvent.5.d
	
	
	trigger = {
		has_war = no
		NOT = { has_idea = depression }
	}
	
	mean_time_to_happen = {
		days = 2000
		modifier = {
			factor = 0.3
			has_idea = economic_boom
		}
		modifier = {
			factor = 0.6
			has_idea = fast_growth
		}
		modifier = {
			factor = 1.3
			has_idea = recession
		}
		modifier = {
			factor = 0.5
			has_country_flag = voodoo_economics
		}
		modifier = {
			factor = 0.5
			has_country_flag = stock_market_crash
		}
		modifier = {
			factor = 0.5
			has_country_flag = housing_crash
		}
	}
	
	immediate = {
		set_country_flag = {
			 flag = consumption_slowdown
			 value = 1
		 }
	}
	
	#Transfer some shopping money
	option = {
		name = econvent.5.a
		log = "[GetDateText]: [This.GetName]: econvent.5.a executed"
		trigger = { has_idea = economic_boom }
		hidden_effect = { country_event = { id = econvent_remove_flag.5 days = 365 } } #clears consumption_slowdown flag
		#increase_debtcount_by_6 = yes
		#custom_effect_tooltip = econvent.debt_5p_tt
		custom_effect_tooltip = econvent.from_booming_tt
		random_list = {
			60 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			40 = {
				custom_effect_tooltip = econvent.list.fast_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = fast_growth }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.5.a
		log = "[GetDateText]: [This.GetName]: econvent.5.a executed"
		trigger = { has_idea = fast_growth }
		hidden_effect = { country_event = { id = econvent_remove_flag.5 days = 365 } } #clears consumption_slowdown flag
		#increase_debtcount_by_6 = yes
		#custom_effect_tooltip = econvent.debt_5p_tt
		custom_effect_tooltip = econvent.from_fast_growth_tt
		random_list = {
			60 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			40 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.5.a
		log = "[GetDateText]: [This.GetName]: econvent.5.a executed"
		trigger = { has_idea = stable_growth }
		hidden_effect = { country_event = { id = econvent_remove_flag.5 days = 365 } } #clears consumption_slowdown flag
		#increase_debtcount_by_6 = yes
		#custom_effect_tooltip = econvent.debt_5p_tt
		custom_effect_tooltip = econvent.stable_growth
		random_list = {
			60 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			40 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.5.a
		log = "[GetDateText]: [This.GetName]: econvent.5.a executed"
		trigger = { has_idea = stagnation }
		hidden_effect = { country_event = { id = econvent_remove_flag.5 days = 365 } } #clears consumption_slowdown flag
		#increase_debtcount_by_6 = yes
		#custom_effect_tooltip = econvent.debt_5p_tt
		custom_effect_tooltip = econvent.from_stagnation_tt
		random_list = {
			60 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			40 = {
				custom_effect_tooltip = econvent.list.recession_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = recession }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.5.a
		log = "[GetDateText]: [This.GetName]: econvent.5.a executed"
		trigger = { has_idea = recession }
		hidden_effect = { country_event = { id = econvent_remove_flag.5 days = 365 } } #clears consumption_slowdown flag
		#increase_debtcount_by_6 = yes
		#custom_effect_tooltip = econvent.debt_5p_tt
		custom_effect_tooltip = econvent.from_recession_tt
		random_list = {
			60 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			40 = {
				custom_effect_tooltip = econvent.list.depression_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = depression }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	
	#Do nothing
	option = {
		name = econvent.5.b
		log = "[GetDateText]: [This.GetName]: econvent.5.b executed"
		trigger = { has_idea = economic_boom }
		hidden_effect = { country_event = { id = econvent_remove_flag.5 days = 365 } } #clears consumption_slowdown flag
		custom_effect_tooltip = econvent.from_booming_tt
		random_list = {
			80 = {
				custom_effect_tooltip = econvent.list.fast_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = fast_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			20 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.5.b
		log = "[GetDateText]: [This.GetName]: econvent.5.b executed"
		trigger = { has_idea = fast_growth }
		hidden_effect = { country_event = { id = econvent_remove_flag.5 days = 365 } } #clears consumption_slowdown flag
		custom_effect_tooltip = econvent.from_fast_growth_tt
		random_list = {
			85 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			15 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.5.b
		log = "[GetDateText]: [This.GetName]: econvent.5.b executed"
		trigger = { has_idea = stable_growth }
		hidden_effect = { country_event = { id = econvent_remove_flag.5 days = 365 } } #clears consumption_slowdown flag
		custom_effect_tooltip = econvent.from_stable_growth_tt
		random_list = {
			90 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
			10 = {
			custom_effect_tooltip = econvent.list.recession_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = recession }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.5.b
		log = "[GetDateText]: [This.GetName]: econvent.5.b executed"
		trigger = { has_idea = stagnation }
		hidden_effect = { country_event = { id = econvent_remove_flag.5 days = 365 } } #clears consumption_slowdown flag
		custom_effect_tooltip = econvent.from_stagnation_tt
		random_list = {
			10 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			80 = {
				custom_effect_tooltip = econvent.list.recession_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = recession }
				clr_country_flag = disable_cycle_costs
				
			}
			10 = {
				custom_effect_tooltip = econvent.list.depression_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = depression }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.5.b
		log = "[GetDateText]: [This.GetName]: econvent.5.b executed"
		trigger = { has_idea = recession }
		hidden_effect = { country_event = { id = econvent_remove_flag.5 days = 365 } } #clears consumption_slowdown flag
		custom_effect_tooltip = econvent.from_recession_tt
		random_list = {
			20 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			80 = {
				custom_effect_tooltip = econvent.list.depression_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = depression }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
}

### Lower demand for our goods in int. markets
country_event = {
	id = econvent.6
	title = econvent.6.t
	desc = econvent.6.d
	
	
	trigger = {
		has_war = no
		NOT = { has_idea = depression }
	}
	
	mean_time_to_happen = {
		days = 1500
		modifier = {
			factor = 0.6
			has_idea = economic_boom
		}
		modifier = {
			factor = 0.8
			has_idea = fast_growth
		}
		modifier = {
			factor = 2.5
			has_idea = recession
		}
	}
	
	#Not much to do about this
	option = {
		name = econvent.6.a
		log = "[GetDateText]: [This.GetName]: econvent.6.a executed"
		trigger = { has_idea = economic_boom }
		custom_effect_tooltip = econvent.from_booming_tt
		random_list = {
			20 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			70 = {
				custom_effect_tooltip = econvent.list.fast_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = fast_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			10 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.6.a
		log = "[GetDateText]: [This.GetName]: econvent.6.a executed"
		trigger = { has_idea = fast_growth }
		custom_effect_tooltip = econvent.from_fast_growth_tt
		random_list = {
			20 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			75 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			5 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.6.a
		log = "[GetDateText]: [This.GetName]: econvent.6.a executed"
		trigger = { has_idea = stable_growth }
		custom_effect_tooltip = econvent.from_stable_growth_tt
		random_list = {
			20 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			80 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.6.a
		log = "[GetDateText]: [This.GetName]: econvent.6.a executed"
		trigger = { has_idea = stagnation }
		custom_effect_tooltip = econvent.from_stagnation_tt
		random_list = {
			25 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			75 = {
				custom_effect_tooltip = econvent.list.recession_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = recession }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.6.a
		log = "[GetDateText]: [This.GetName]: econvent.6.a executed"
		trigger = { has_idea = recession }
		custom_effect_tooltip = econvent.from_recession_tt
		random_list = {
			50 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			50 = {
				custom_effect_tooltip = econvent.list.depression_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = depression }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
}

#### Things for poor countries ####
###Work in progress

### Drought!
country_event = {
	id = econvent.7
	title = econvent.7.t
	desc = econvent.7.d
	
	
	trigger = {
		is_arid_nation = yes
		OR = {
			has_idea = gdp_1
			has_idea = gdp_2
			has_idea = gdp_3	
		}
		NOT = { has_idea = depression }
	}
	
	mean_time_to_happen = {
		days = 2800
		modifier = {
			factor = 0.6
			is_african_nation = yes #Africa has worst irrigation
		}
		modifier = {
			factor = 0.8
			has_idea = gdp_1
		}
		modifier = {
			factor = 0.9
			has_idea = gdp_2
		}
		modifier = {
			factor = 1.2
			has_idea = gdp_3
		}
	}
	
	immediate = {
		set_country_flag = {
			 flag = drought
			 value = 1
		 }
	}
	
	#Not much to do about this
	option = {
		name = econvent.7.a
		log = "[GetDateText]: [This.GetName]: econvent.7.a executed"
		trigger = { has_idea = economic_boom }
		hidden_effect = { country_event = { id = econvent_remove_flag.6 days = 120 } } #clears drought flag
		custom_effect_tooltip = econvent.from_booming_tt
		random_list = {
			20 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			70 = {
				custom_effect_tooltip = econvent.list.fast_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = fast_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			10 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.7.a
		log = "[GetDateText]: [This.GetName]: econvent.7.a executed"
		trigger = { has_idea = fast_growth }
		hidden_effect = { country_event = { id = econvent_remove_flag.6 days = 120 } } #clears drought flag
		custom_effect_tooltip = econvent.from_fast_growth_tt
		random_list = {
			20 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			75 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			5 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.7.a
		log = "[GetDateText]: [This.GetName]: econvent.7.a executed"
		trigger = { has_idea = stable_growth }
		hidden_effect = { country_event = { id = econvent_remove_flag.6 days = 120 } } #clears drought flag
		custom_effect_tooltip = econvent.from_stable_growth_tt
		random_list = {
			20 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			80 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.7.a
		log = "[GetDateText]: [This.GetName]: econvent.7.a executed"
		trigger = { has_idea = stagnation }
		hidden_effect = { country_event = { id = econvent_remove_flag.6 days = 120 } } #clears drought flag
		custom_effect_tooltip = econvent.from_stagnation_tt
		random_list = {
			25 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			75 = {
				custom_effect_tooltip = econvent.list.recession_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = recession }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.7.a
		log = "[GetDateText]: [This.GetName]: econvent.7.a executed"
		trigger = { has_idea = recession }
		hidden_effect = { country_event = { id = econvent_remove_flag.6 days = 120 } } #clears drought flag
		custom_effect_tooltip = econvent.from_recession_tt
		random_list = {
			50 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			50 = {
				custom_effect_tooltip = econvent.list.depression_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = depression }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
}

### Drought causes famine
country_event = {
	id = econvent.8
	title = econvent.8.t
	desc = econvent.8.d
	
	trigger = {
	has_country_flag = drought
	NOT = { has_idea = depression }
	}
	
	mean_time_to_happen = {
		days = 1200
		modifier = {
			factor = 0.7
			has_idea = gdp_1
		}
		modifier = {
			factor = 0.9
			has_idea = gdp_2
		}
		modifier = {
			factor = 1.2
			has_idea = gdp_3
		}
	}
	
	immediate = {
		set_country_flag = {
			 flag = famine
			 value = 1
		 }
	}
	
	#Not much to do about this
	option = {
		name = econvent.8.a
		log = "[GetDateText]: [This.GetName]: econvent.8.a executed"
		trigger = { has_idea = economic_boom }
		hidden_effect = { country_event = { id = econvent_remove_flag.7 days = 200 } } #clears famine flag
		custom_effect_tooltip = econvent.from_booming_tt
		random_list = {
			20 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			70 = {
				custom_effect_tooltip = econvent.list.fast_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = fast_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			10 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.8.a
		log = "[GetDateText]: [This.GetName]: econvent.8.a executed"
		trigger = { has_idea = fast_growth }
		hidden_effect = { country_event = { id = econvent_remove_flag.7 days = 200 } } #clears famine flag
		custom_effect_tooltip = econvent.from_fast_growth_tt
		random_list = {
			20 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			75 = {
				custom_effect_tooltip = econvent.list.stable_growth_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stable_growth }
				clr_country_flag = disable_cycle_costs
				
			}
			5 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.8.a
		log = "[GetDateText]: [This.GetName]: econvent.8.a executed"
		trigger = { has_idea = stable_growth }
		hidden_effect = { country_event = { id = econvent_remove_flag.7 days = 200 } } #clears famine flag
		custom_effect_tooltip = econvent.from_stable_growth_tt
		random_list = {
			20 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			80 = {
				custom_effect_tooltip = econvent.list.stagnation_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = stagnation }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.8.a
		log = "[GetDateText]: [This.GetName]: econvent.8.a executed"
		trigger = { has_idea = stagnation }
		hidden_effect = { country_event = { id = econvent_remove_flag.7 days = 200 } } #clears famine flag
		custom_effect_tooltip = econvent.from_stagnation_tt
		random_list = {
			25 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			75 = {
				custom_effect_tooltip = econvent.list.recession_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = recession }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
	option = {
		name = econvent.8.a
		log = "[GetDateText]: [This.GetName]: econvent.8.a executed"
		trigger = { has_idea = recession }
		hidden_effect = { country_event = { id = econvent_remove_flag.7 days = 200 } } #clears famine flag
		custom_effect_tooltip = econvent.from_recession_tt
		random_list = {
			50 = {
				custom_effect_tooltip = econvent.list.no_effect_tt
			}
			50 = {
				custom_effect_tooltip = econvent.list.depression_tt
				set_country_flag = disable_cycle_costs
				hidden_effect = { add_ideas = depression }
				clr_country_flag = disable_cycle_costs
				
			}
		}
	}
}

#clears housing_crash flag
country_event = {
	id = econvent_remove_flag.1

	is_triggered_only = yes
	hidden = yes
	
	immediate = {
		clr_country_flag = housing_crash
	}
}

#clears voodoo_economics flag
country_event = {
	id = econvent_remove_flag.2

	is_triggered_only = yes
	hidden = yes
	
	immediate = {
		clr_country_flag = voodoo_economics
	}
	
	option = {
		name = econvent_remove_flag.2.a
		log = "[GetDateText]: [This.GetName]: econvent_remove_flag.2.a executed"
	}
}
#clears stock_market_crash flag
country_event = {
	id = econvent_remove_flag.3

	is_triggered_only = yes
	hidden = yes
	
	immediate = {
		clr_country_flag = stock_market_crash
	}
	
	option = {
		name = econvent_remove_flag.3.a
		log = "[GetDateText]: [This.GetName]: econvent_remove_flag.3.a executed"
	}
}
#clears bank_crisis flag
country_event = {
	id = econvent_remove_flag.4

	is_triggered_only = yes
	hidden = yes
	
	immediate = {
		clr_country_flag = bank_crisis
	}
	
	option = {
		name = econvent_remove_flag.4.a
		log = "[GetDateText]: [This.GetName]: econvent_remove_flag.4.a executed"
	}
}
#clears consumption_slowdown flag
country_event = {
	id = econvent_remove_flag.5

	is_triggered_only = yes
	hidden = yes
	
	immediate = {
		clr_country_flag = consumption_slowdown
	}
	
	option = {
		name = econvent_remove_flag.5.a
		log = "[GetDateText]: [This.GetName]: econvent_remove_flag.5.a executed"
	}
}
#clears drought flag
country_event = {
	id = econvent_remove_flag.6

	is_triggered_only = yes
	hidden = yes
	
	immediate = {
		clr_country_flag = drought
	}
	
	option = {
		name = econvent_remove_flag.6.a
		log = "[GetDateText]: [This.GetName]: econvent_remove_flag.6.a executed"
	}
}
#clears famine flag
country_event = {
	id = econvent_remove_flag.7

	is_triggered_only = yes
	hidden = yes
	
	immediate = {
		clr_country_flag = famine
	}
	
	option = {
		name = econvent_remove_flag.7.a
		log = "[GetDateText]: [This.GetName]: econvent_remove_flag.7.a executed"
	}
}

##Generic Loss of Industry##
country_event = {
	id = econvent.100
	title = econvent.100.t
	desc = econvent.100.d

	is_triggered_only = yes
	
	option = {
		name = econvent.100.a
		set_variable = { reduction_factor = 0.1 }
		#log = "ecovent100 evt: Lose §R[?reduction_factor|%0]§! of civilian factories."
		#log = "Ind: [?reduction_factor] [?reduction_factor|%0]"
		remove_civilian_industry_effect = yes
		#remove_civilian_industry_small_effect = yes
		log = "[GetDateText]: [This.GetName]: econvent.100.a executed"
	}
}

##Industry Relocates##
country_event = {
	id = econvent.101
	title = econvent.101.t
	desc = econvent.101.d

	is_triggered_only = yes
	
	option = {
		name = econvent.101.a
		set_variable = { reduction_factor = 0.1 }
		#log = "2Lose §R[?reduction_factor|%0]§! of civilian factories."
		#log = "Ind: [?reduction_factor] [?reduction_factor|%0]"
		migrate_industry_to_random_effect = yes
		log = "[GetDateText]: [This.GetName]: econvent.101.a executed"
	}
}

country_event = {
	id = econvent.102
	title = econvent.102.t
	desc = econvent.102.d

	is_triggered_only = yes
	
	option = {
		name = econvent.102.a
		custom_effect_tooltip = factories_migrated_to_us_tt # <ind_factories> Factories from <FROM> have relocate somewhere in <ROOT>.
		hidden_effect = {
			FROM = {
				set_variable = { iterations = 0 }
			}
			civ_factory_relocate_from_from_build_loop_effect = yes
		}
		log = "[GetDateText]: [This.GetName]: econvent.102.a executed"
	}
}


