add_namespace = random

# Concerns about succession (Up to Machine Era)
country_event = {
	id = random.1
	title = random.1.t
	desc = random.1.d
	picture = GFX_report_event_gathering_protest

	trigger = {
		OR = {
			has_idea = pre_industrial_era
			has_idea = victorian_era
			has_idea = machine_era
		}
		has_government = autocracy
	}

	mean_time_to_happen = {
		days = 1600
	}

	option = {
		name = random.1.a
		ai_chance = { factor = 100 }
		add_political_power = -50
		add_war_support = 0.02
		add_stability = -0.1
	}
}

# Country stands united (Peace) (Up to Machine Era)
country_event = {
	id = random.2
	title = random.2.t
	desc = random.2.d
	picture = GFX_report_event_journalists_speech

	trigger = {
		has_stability > 0.8
		has_war = no
		OR = {
			has_idea = pre_industrial_era
			has_idea = victorian_era
			has_idea = machine_era
		}
	}

	mean_time_to_happen = {
		days = 900
	}

	option = {
		name = random.2.a
		ai_chance = { factor = 80 }
		add_political_power = 75
	}

	option = {
		name = random.2.b
		ai_chance = { factor = 20 }
		add_timed_idea = { idea = eoanb_random_event_2_idea days = 90 }
	}
}

# High Military Funding leads to Doctrine Discovery
country_event = {
	id = random.3
	title = random.3.t
	desc = random.3.d
	picture = GFX_report_event_germany_politician_handshake

	trigger = {
		has_idea = army_spending_level_4
		NOT = { has_idea = pre_industrial_era }
		has_stability > 0.5
	}

	mean_time_to_happen = {
		days = 1200
	}

	option = {
		name = random.3.a
		ai_chance = { factor = 100 }
		add_doctrine_cost_reduction = { cost_reduction = 0.3 uses = 1 category = land_doctrine }
	}
}

# Infrastructure develops due to Industrialization (Victorian Era)
country_event = {
	id = random.4
	title = random.4.t
	desc = random.4.d
	picture = GFX_report_event_burma_road

	trigger = {
		has_idea = industrializing
		has_idea = victorian_era
		NOT = {
			has_government = ideology_radical_socialism
			has_government = anarchism
			tag = DEN
			tag = SAX
		}
		OR = {
			centrism > 0.075
			traditional_conservatism > 0.15
			social_egalitarianism > 0.3
		}
	}

	mean_time_to_happen = {
		days = 2800
	}

	option = {
		name = random.4.a
		ai_chance = { factor = 100 }
		add_1_infra_random_state = yes
	}
}

# Feeling threatened by the Ottomans (Up to Machine Era)
country_event = {
	id = random.6
	title = random.6.t
	desc = random.6.d
	picture = GFX_report_event_generic_conference

	trigger = {
		is_neighbor_of = OTO
		OTO = { num_of_controlled_states > 20 }
		NOT = { 
			has_war_with = OTO
			tag = AUS
			is_subject_of = OTO
		}
		OR = {
			ic_ratio = { tag = OTO ratio < 0.5 }
			strength_ratio = { tag = OTO ratio < 0.75 }
		}
		OR = {
			has_idea = pre_industrial_era
			has_idea = victorian_era
			has_idea = machine_era
		}
	}

	mean_time_to_happen = {
		days = 1200
	}

	option = {
		name = random.6.a
		ai_chance = { factor = 100 }
		add_political_power = -25
		add_manpower = 1000
	}
}

# Local artist creates a great piece of work (Up to Machine Era)
country_event = {
	id = random.7
	title = random.7.t
	desc = random.7.d
	picture = GFX_report_event_aid_pact

	is_triggered_only = yes
	
	trigger = {
		has_stability > 0.5
		OR = {
			has_idea = privileged_education
			has_idea = open_schools
			has_idea = compulsory_education
		}
	}

	option = {
		name = random.7.a
		ai_chance = { factor = 100 }
		add_political_power = 40
	}
}

# Genius Inventor (Aviation) (Victorian Age)
country_event = {
	id = random.8
	title = random.8.t
	desc = random.8.d
	picture = GFX_report_event_generic_research_lab

	trigger = {
		NOT = { has_war = yes }
		has_stability > 0.4
		has_idea = victorian_era
		OR = {
			has_idea = privileged_education
			has_idea = open_schools
			has_idea = compulsory_education
		}
	}

	mean_time_to_happen = {
		days = 6000
	}

	option = {
		name = random.8.a
		ai_chance = { factor = 100 }
		add_political_power = -5
		add_tech_bonus = { bonus = 0.75 uses = 1 category = aviation_tech }
	}
}

# People demand more rights (Up to Machine Era)
#country_event = {
#	id = random.9
#	title = random.9.t
#	desc = random.9.d
#	picture = GFX_report_event_gathering_protest
#
#	trigger = {
#		has_idea = absolutism
#		autocracy < 0.9
#		has_stability < 0.6
#		OR = {
#			has_idea = pre_industrial_era
#			has_idea = victorian_era
#			has_idea = machine_era
#		}
#	}
#
#	mean_time_to_happen = {
#		days = 1500
#	}
#
#	option = {
#		name = random.9.a
#		ai_chance = { factor = 60 }
#		add_political_power = -250
#	}
#
#	option = {
#		name = random.9.b
#		ai_chance = { factor = 40 }
#		add_political_power = -50
#		custom_effect_tooltip = random_event_9_b_tt
#		hidden_effect = {
#			swap_ideas = { remove_idea = absolutism add_idea = parliamentary_suffrage }
#		}
#	}
#}

# Politicians question the current government (Up to Machine Era)
country_event = {
	id = random.10
	title = random.10.t
	desc = random.10.d
	picture = GFX_report_event_generic_parliament

	trigger = {
		NOT = { 
			has_stability > 0.9
			has_idea = absolutism
		}
		OR = {
			has_idea = parliamentary_suffrage
			has_idea = property_owners_suffrage
			has_idea = universal_male_suffrage
			has_idea = universal_suffrage
		}
		OR = {
			has_idea = pre_industrial_era
			has_idea = victorian_era
			has_idea = machine_era
		}
	}

	mean_time_to_happen = {
		days = 3200
	}

	option = {
		name = random.10.a
		ai_chance = { factor = 100 }
		add_timed_idea = { idea = eoanb_random_event_10_idea days = 90 }
	}
}

# Inspiring War Speech (Victorian Age)
country_event = {
	id = random.11
	title = random.11.t
	desc = random.11.d
	picture = GFX_report_event_chinese_soldiers_fighting

	trigger = {
		has_war = yes
		has_idea = victorian_era
		has_stability < 0.85
	}

	mean_time_to_happen = {
		days = 1200
	}

	option = {
		name = random.11.a
		ai_chance = { factor = 100 }
		add_timed_idea = { idea = eoanb_random_event_11_idea days = 180 }
	}
}

# Capitalist funds new cotton farm (Victorian Era)
country_event = {
	id = random.12
	title = random.12.t
	desc = random.12.d
	picture = GFX_report_event_ast_troops_landing

	trigger = {
		NOT = {
			OR = {
				tag = AUS
				tag = BAD
				tag = DEN
				tag = PRS
				tag = SAX
			}
			has_government = ideology_radical_socialism
			has_government = anarchism
		}
		OR = {
			has_idea = industrializing
			has_idea = agrarian
		}
		has_idea = victorian_era
		OR = {
			centrism > 0.1
			traditional_conservatism > 0.25
			social_egalitarianism > 0.5
		}
	}

	mean_time_to_happen = {
		days = 5000
	}

	option = {
		name = random.12.a
		ai_chance = { factor = 100 }
		add_1_cotton_farm_random_state = yes
	}
}

# Comet sighted (Victorian Era)
country_event = {
	id = random.13
	title = random.13.t
	desc = random.13.d
	picture = GFX_report_event_generic_riot

	trigger = {
		has_idea = victorian_era
	}

	mean_time_to_happen = {
		days = 6000
	}

	option = {
		name = random.13.a
		ai_chance = { factor = 25 }
		add_stability = -0.01
	}

	option = {
		name = random.13.b
		ai_chance = { factor = 25 }
		add_stability = -0.01
	}

	option = {
		name = random.13.c
		ai_chance = { factor = 25 }
		add_stability = -0.01
	}

	option = {
		name = random.13.e
		ai_chance = { factor = 25 }
		add_stability = -0.01
	}
}

# Industrialization attracts people to cities (Up to Oil Era)
country_event = {
	id = random.14
	title = random.14.t
	desc = random.14.d
	picture = GFX_report_event_generic_factory

	trigger = {
		has_idea = industrializing
		NOT = { has_idea = tribal_slavery }
		num_of_controlled_states > 3
		OR = {
			has_idea = victorian_era
			has_idea = machine_era
			has_idea = oil_era
		}
	}

	mean_time_to_happen = {
		days = 1825
	}

	option = {
		name = random.14.a
		ai_chance = { factor = 100 }
		random_owned_controlled_state = {
			limit = {
				is_capital = no
				is_island_state = no
				is_in_home_area = yes
			}
			add_manpower = -1000
		}
		capital_scope = { add_manpower = 1000 }
	}
}

# Dispute over Constitution (Up to Machine Era)
country_event = {
	id = random.15
	title = random.15.t
	desc = random.15.d
	picture = GFX_report_event_generic_conference

	trigger = {
		NOT = { has_idea = absolutism }
		has_stability < 0.9
		OR = {
			has_idea = pre_industrial_era
			has_idea = victorian_era
			has_idea = machine_era
		}
	}

	mean_time_to_happen = {
		days = 3650
	}

	option = {
		name = random.15.a
		ai_chance = { factor = 40 }
		add_stability = -0.01
	}

	option = {
		name = random.15.b
		ai_chance = { factor = 60 }
		add_political_power = -30
		add_stability = 0.01
	}
}

# Problems funding schools (Up to Oil Era)
country_event = {
	id = random.16
	title = random.16.t
	desc = random.16.d
	picture = GFX_report_event_ast_parliament_house

	is_triggered_only = yes

	trigger = {
		has_idea = open_schools
		has_stability < 0.7
		NOT = {
			tag = AUS
			tag = PRS
			tag = SAX
		}
	}

	option = {
		name = random.16.a
		ai_chance = { factor = 70 }
		add_political_power = -50
	}

	option = {
		name = random.16.b
		ai_chance = { factor = 30 }
		custom_effect_tooltip = eoanb_tt_event_random_16
		hidden_effect = {
			swap_ideas = { remove_idea = open_schools add_idea = privileged_education }
		}
	}
}

# High Taxes lead to Tax Evasion (Up to Machine Era)
country_event = {
	id = random.17
	title = random.17.t
	desc = random.17.d
	picture = GFX_news_event_generic_read_write

	trigger = {
		has_idea = taxation_level_4
		OR = {
			has_idea = pre_industrial_era
			has_idea = victorian_era
			has_idea = machine_era
		}
	}

	mean_time_to_happen = {
		days = 8000
	}

	option = {
		name = random.17.a
		ai_chance = { factor = 50 }
		add_timed_idea = { idea = eoanb_random_event_17_idea days = 180 }
	}

	option = {
		name = random.17.b
		ai_chance = { factor = 50 }
		custom_effect_tooltip = eoanb_tt_event_random_17
		hidden_effect = {
			swap_ideas = { remove_idea = taxation_level_4 add_idea = taxation_level_3 }
		}
	}
}

# CONSOLIDATED: Peacetime Economy Transition Event
country_event = {
	id = random.18
	title = random.18.t
	desc = random.18.d
	picture = GFX_report_event_worker_protests

	trigger = {
		has_war = no
		NOT = { tag = PRS }
		OR = {
			has_idea = tot_economic_mobilisation
			has_idea = war_economy
			has_idea = partial_economic_mobilisation
			has_idea = low_economic_mobilisation
		}
		OR = {
			has_idea = pre_industrial_era
			has_idea = victorian_era
			has_idea = machine_era
		}
	}

	mean_time_to_happen = {
		days = 90
		modifier = {
			factor = 1.33
			has_idea = war_economy
		}
		modifier = {
			factor = 1.67
			has_idea = partial_economic_mobilisation
		}
		modifier = {
			factor = 2
			has_idea = low_economic_mobilisation
		}
	}

	option = {
		name = random.18.a
		trigger = { has_idea = tot_economic_mobilisation }
		ai_chance = { factor = 90 }
		swap_ideas = { remove_idea = tot_economic_mobilisation add_idea = civilian_economy }
	}

	option = {
		name = random.19.a
		trigger = { has_idea = war_economy }
		ai_chance = { factor = 90 }
		swap_ideas = { remove_idea = war_economy add_idea = civilian_economy }
	}

	option = {
		name = random.20.a
		trigger = { has_idea = partial_economic_mobilisation }
		ai_chance = { factor = 85 }
		swap_ideas = { remove_idea = partial_economic_mobilisation add_idea = civilian_economy }
	}

	option = {
		name = random.21.a
		trigger = { has_idea = low_economic_mobilisation }
		ai_chance = { factor = 80 }
		swap_ideas = { remove_idea = low_economic_mobilisation add_idea = civilian_economy }
	}

	option = {
		name = random.18.b
		trigger = { has_idea = tot_economic_mobilisation }
		ai_chance = { factor = 10 }
		add_political_power = -200
		add_stability = -0.05
		custom_effect_tooltip = eoanb_tt_event_random_18_b
	}

	option = {
		name = random.19.b
		trigger = { has_idea = war_economy }
		ai_chance = { factor = 10 }
		add_political_power = -80
		add_stability = -0.03
		custom_effect_tooltip = eoanb_tt_event_random_19_b
	}

	option = {
		name = random.20.b
		trigger = { has_idea = partial_economic_mobilisation }
		ai_chance = { factor = 15 }
		add_political_power = -20
		add_stability = -0.02
		custom_effect_tooltip = eoanb_tt_event_random_20_b
	}

	option = {
		name = random.21.b
		trigger = { has_idea = low_economic_mobilisation }
		ai_chance = { factor = 20 }
		add_political_power = -10
		add_stability = -0.01
		custom_effect_tooltip = eoanb_tt_event_random_21_b
	}
}

# Country is at Peace with Civilian Economy (Up to Machine Era)
country_event = {
	id = random.22
	title = random.22.t
	desc = random.22.d
	picture = GFX_report_event_generic_military_parade

	trigger = {
		has_war = no
		has_idea = civilian_economy
		OR = {
			has_idea = pre_industrial_era
			has_idea = victorian_era
			has_idea = machine_era
		}
	}

	mean_time_to_happen = {
		days = 3650
	}

	option = {
		name = random.22.a
		ai_chance = { factor = 100 }
		if = {
			limit = { has_variable = has_afr_empire_mechanic_system }
			custom_effect_tooltip = afr_empire_politics_minor_economic_boom_effect
		}
		else_if = {
			limit = {
				any_state = {
					is_claimed_by = ROOT
					check_variable = { var = UCT_territory_management_colonization_progress_var value = 0 compare = greater_than }
					check_variable = { var = UCT_territory_management_colonization_progress_var value = 100 compare = less_than }
				}
			}
			custom_effect_tooltip = UCT_territory_management_minor_economic_boom_effect
		}
		add_timed_idea = { idea = eoanb_random_event_22_idea days = 90 }
		hidden_effect = {
			if = {
				limit = {
					any_state = {
						is_claimed_by = ROOT
						check_variable = { var = UCT_territory_management_colonization_progress_var value = 0 compare = greater_than }
						check_variable = { var = UCT_territory_management_colonization_progress_var value = 100 compare = less_than }
					}
				}
				every_state = {
					limit = { 
						is_claimed_by = ROOT
						check_variable = { var = UCT_territory_management_colonization_progress_var value = 0 compare = greater_than }
						check_variable = { var = UCT_territory_management_colonization_progress_var value = 100 compare = less_than }
					}
					state_event = { id = RCE_afr_regional_power.61 days = 90 trigger_for = controller }
					set_state_flag = afr_empire_politics_minor_economic_boom_event_flag
				}
			}
		}
	}
}

# Minor Flooding in coastal state (Up to Oil Era)
country_event = {
	id = random.23
	title = random.23.t
	desc = random.23.d
	picture = GFX_report_event_generic_flooding

	is_triggered_only = yes

	trigger = {
		any_owned_state = {
			is_coastal = yes
			infrastructure > 0
		}
	}

	option = {
		name = random.23.a
		ai_chance = {
			factor = 50
			modifier = {
				factor = 1.2
				has_political_power > 50
			}
			modifier = {
				factor = 1.4
				has_political_power > 100
			}
		}
		add_political_power = -60
		random_owned_controlled_state = {
			limit = {
				is_coastal = yes
				infrastructure > 0
			}
			random_list = {
				40 = {
					remove_building = {
						type = infrastructure
						level = 1
					}
				}
				30 = {
					damage_building = {
						type = infrastructure
						damage = 1.5
					}
				}
				25 = {
					damage_building = {
						type = infrastructure
						damage = 0.5
					}
				}
				5 = {
					damage_building = {
						type = infrastructure
						damage = 0.1
					}
				}
			}
		}
	}

	option = {
		name = random.23.b
		ai_chance = { factor = 50 }
		add_political_power = -20
		add_timed_idea = {
			idea = eoanb_random_event_23_idea
			days = 200
		}
	}
}

# Weapon Technology advances during a war (Victorian Era)
country_event = {
	id = random.24
	title = random.24.t
	desc = random.24.d
	picture = GFX_report_event_canada_army

	trigger = {
		has_war = yes
		has_idea = victorian_era
		amount_research_slots > 1
	}

	mean_time_to_happen = {
		days = 1500
	}

	option = {
		name = random.24.a
		ai_chance = { factor = 100 }
		add_tech_bonus = { bonus = 0.5 uses = 1 category = infantry_weapons }
	}
}
