﻿# Era Momentum objectives. These are intentionally country-relative: small
# countries can qualify through structural progress while large powers can
# qualify through scale.

ve_age_objective_1_trigger = {
	trigger_if = {
		limit = { has_global_variable = ve_age_1_started }
		pop_type_percent_country = {
			pop_type = peasants
			percent < 0.40
		}
	}
	trigger_else_if = {
		limit = { has_global_variable = ve_age_2_started }
		OR = {
			GDP >= 100000000
			pop_type_percent_country = {
				pop_type = peasants
				percent < 0.25
			}
		}
	}
	trigger_else_if = {
		limit = { has_global_variable = ve_age_3_started }
		OR = {
			has_law = law_type:law_universal_suffrage
			has_law = law_type:law_council_republic
			AND = {
				OR = {
					has_law = law_type:law_parliamentary_republic
					has_law = law_type:law_presidential_republic
				}
				government_legitimacy >= 75
			}
		}
	}
}

ve_age_objective_2_trigger = {
	trigger_if = {
		limit = { has_global_variable = ve_age_1_started }
		has_law = law_type:law_slavery_banned
		NOT = { has_law = law_type:law_serfdom }
	}
	trigger_else_if = {
		limit = { has_global_variable = ve_age_2_started }
		OR = {
			literacy_rate >= 0.65
			institution_investment_level = {
				institution = institution_schools
				value >= 4
			}
		}
	}
	trigger_else_if = {
		limit = { has_global_variable = ve_age_3_started }
		calc_true_if = {
			amount >= 2
			institution_investment_level = {
				institution = institution_health_system
				value >= 3
			}
			institution_investment_level = {
				institution = institution_social_security
				value >= 3
			}
			institution_investment_level = {
				institution = institution_workplace_safety
				value >= 3
			}
			institution_investment_level = {
				institution = institution_schools
				value >= 3
			}
		}
	}
}

ve_age_objective_3_trigger = {
	trigger_if = {
		limit = { has_global_variable = ve_age_1_started }
		government_legitimacy >= 70
		bureaucracy >= 0
		approaching_bureaucracy_shortage = no
	}
	trigger_else_if = {
		limit = { has_global_variable = ve_age_2_started }
		OR = {
			any_subject_or_below = { count >= 2 }
			AND = {
				is_subject = no
				is_country_type = recognized
			}
		}
	}
	trigger_else_if = {
		limit = { has_global_variable = ve_age_3_started }
		OR = {
			AND = {
				total_population < 10000000
				country_has_building_type_levels = {
					target = bt:building_power_plant
					value >= 1
				}
			}
			country_has_building_type_levels = {
				target = bt:building_power_plant
				value >= 5
			}
		}
	}
}

ve_age_objective_4_trigger = {
	trigger_if = {
		limit = { has_global_variable = ve_age_1_started }
		OR = {
			literacy_rate >= 0.50
			institution_investment_level = {
				institution = institution_schools
				value >= 3
			}
		}
	}
	trigger_else_if = {
		limit = { has_global_variable = ve_age_2_started }
		OR = {
			AND = {
				total_population < 10000000
				country_has_building_type_levels = {
					target = bt:building_port
					value >= 2
				}
			}
			country_has_building_type_levels = {
				target = bt:building_port
				value >= 10
			}
			any_scope_interest_marker = {
				count >= 5
			}
		}
	}
	trigger_else_if = {
		limit = { has_global_variable = ve_age_3_started }
		OR = {
			country_has_building_type_levels = {
				target = bt:building_oil_rig
				value >= 1
			}
			country_has_building_type_levels = {
				target = bt:building_motor_industry
				value >= 5
			}
		}
	}
}

ve_age_objective_5_trigger = {
	trigger_if = {
		limit = { has_global_variable = ve_age_1_started }
		OR = {
			AND = {
				total_population < 5000000
				country_has_building_type_levels = {
					target = bt:building_railway
					value >= 3
				}
			}
			country_has_building_type_levels = {
				target = bt:building_railway
				value >= 6
			}
		}
	}
	trigger_else_if = {
		limit = { has_global_variable = ve_age_2_started }
		country_turmoil < 0.05
		government_legitimacy >= 60
	}
	trigger_else_if = {
		limit = { has_global_variable = ve_age_3_started }
		OR = {
			country_army_unit_type_fraction = {
				target = unit_type:combat_unit_type_trench_infantry
				value >= 0.50
			}
			country_army_unit_type_fraction = {
				target = unit_type:combat_unit_type_squad_infantry
				value >= 0.50
			}
		}
		country_army_unit_type_fraction = {
			target = unit_type:combat_unit_type_shrapnel_artillery
			value >= 0.15
		}
	}
}

ve_age_objective_6_trigger = {
	trigger_if = {
		limit = { has_global_variable = ve_age_1_started }
		is_subject = no
		country_turmoil < 0.05
		government_legitimacy >= 65
	}
	trigger_else_if = {
		limit = { has_global_variable = ve_age_2_started }
		OR = {
			institution_investment_level = {
				institution = institution_health_system
				value >= 2
			}
			institution_investment_level = {
				institution = institution_workplace_safety
				value >= 2
			}
			institution_investment_level = {
				institution = institution_social_security
				value >= 2
			}
		}
	}
	trigger_else_if = {
		limit = { has_global_variable = ve_age_3_started }
		army_size >= 40
		OR = {
			country_has_building_type_levels = {
				target = bt:building_arms_industry
				value >= 5
			}
			country_has_building_type_levels = {
				target = bt:building_munition_plant
				value >= 3
			}
		}
	}
}

ve_age_objective_7_trigger = {
	trigger_if = {
		limit = { has_global_variable = ve_age_1_started }
		OR = {
			country_rank = rank_value:major_power
			country_rank = rank_value:great_power
			any_scope_interest_marker = {
				count >= 5
			}
		}
	}
	trigger_else_if = {
		limit = { has_global_variable = ve_age_2_started }
		OR = {
			country_army_unit_type_fraction = {
				target = unit_type:combat_unit_type_skirmish_infantry
				value >= 0.50
			}
			country_army_unit_type_fraction = {
				target = unit_type:combat_unit_type_trench_infantry
				value >= 0.50
			}
		}
		country_army_unit_type_fraction = {
			target = unit_type:combat_unit_type_mobile_artillery
			value >= 0.10
		}
	}
	trigger_else_if = {
		limit = { has_global_variable = ve_age_3_started }
		OR = {
			country_rank = rank_value:great_power
			country_rank = rank_value:major_power
			is_power_bloc_leader = yes
			any_scope_interest_marker = {
				count >= 6
			}
		}
	}
}

ve_can_purchase_era_reward = {
	OR = {
		AND = {
			var:ve_age_rewards_purchased <= 0
			ve_era_momentum_value >= 200
		}
		AND = {
			var:ve_age_rewards_purchased == 1
			ve_era_momentum_value >= 300
		}
		AND = {
			var:ve_age_rewards_purchased == 2
			ve_era_momentum_value >= 400
		}
		AND = {
			var:ve_age_rewards_purchased == 3
			ve_era_momentum_value >= 500
		}
		AND = {
			var:ve_age_rewards_purchased >= 4
			ve_era_momentum_value >= 600
		}
	}
}

ve_can_purchase_era_reward_slot = {
	ve_can_purchase_era_reward = yes
	OR = {
		AND = {
			has_global_variable = ve_age_1_started
			NOT = { has_modifier = age_1_bonus_$SLOT$ }
		}
		AND = {
			has_global_variable = ve_age_2_started
			NOT = { has_modifier = age_2_bonus_$SLOT$ }
		}
		AND = {
			has_global_variable = ve_age_3_started
			NOT = { has_modifier = age_3_bonus_$SLOT$ }
		}
	}
}

ve_can_purchase_country_era_reward_10 = {
	ve_can_purchase_era_reward = yes
	OR = {
		AND = {
			has_global_variable = ve_age_1_started
			NOT = { has_modifier = age_1_bonus_10 }
			OR = {
				country_has_primary_culture = cu:north_italian
				country_has_primary_culture = cu:south_italian
			}
		}
		AND = {
			has_global_variable = ve_age_2_started
			NOT = { has_modifier = age_2_bonus_10 }
			exists = c:AUS
			this = c:AUS
		}
		AND = {
			has_global_variable = ve_age_3_started
			NOR = {
				has_modifier = age_3_bonus_10
				has_modifier = age_3_bonus_10_2
			}
			exists = c:GBR
			this = c:GBR
		}
	}
}

ve_can_purchase_country_era_reward_11 = {
	ve_can_purchase_era_reward = yes
	OR = {
		AND = {
			has_global_variable = ve_age_1_started
			NOT = { has_modifier = age_1_bonus_11 }
			OR = {
				country_has_primary_culture = cu:north_german
				country_has_primary_culture = cu:south_german
			}
		}
		AND = {
			has_global_variable = ve_age_2_started
			NOT = { has_modifier = age_2_bonus_11 }
			exists = c:RUS
			this = c:RUS
		}
		AND = {
			has_global_variable = ve_age_3_started
			NOT = { has_modifier = age_3_bonus_11 }
			exists = c:CHI
			this = c:CHI
		}
	}
}

ve_can_purchase_country_era_reward_12 = {
	ve_can_purchase_era_reward = yes
	OR = {
		AND = { has_global_variable = ve_age_1_started NOT = { has_modifier = age_1_bonus_12 } exists = c:NET this = c:NET }
		AND = { has_global_variable = ve_age_2_started NOT = { has_modifier = age_2_bonus_12 } exists = c:BEL this = c:BEL }
		AND = { has_global_variable = ve_age_3_started NOT = { has_modifier = age_3_bonus_12 } exists = c:FRA this = c:FRA }
	}
}

ve_can_purchase_country_era_reward_13 = {
	ve_can_purchase_era_reward = yes
	OR = {
		AND = { has_global_variable = ve_age_1_started NOT = { has_modifier = age_1_bonus_13 } exists = c:TUR this = c:TUR }
		AND = { has_global_variable = ve_age_2_started NOT = { has_modifier = age_2_bonus_13 } exists = c:USA this = c:USA }
		AND = { has_global_variable = ve_age_3_started NOT = { has_modifier = age_3_bonus_13 } exists = c:JAP this = c:JAP }
	}
}

ve_golden_age_not_yet_used = {
	NOT = { has_variable = ve_golden_age_used }
}

ve_golden_age_year_reached = {
	year >= 1845
}

ve_golden_age_objective_requirement_met = {
	var:ve_triggered_objectives >= 5
}

ve_can_activate_golden_age = {
	ve_golden_age_not_yet_used = yes
	ve_golden_age_year_reached = yes
	ve_golden_age_objective_requirement_met = yes
}
