﻿#This file contains the effects of the mechanics that countries should have at the start of the game and after it starts
ve_initialize_country_system = {
	if = {
		limit = {
			NOT = { has_variable = victoria_universalis_system_on }
		}
		set_point_system = yes
		set_idea_buttons = yes
		set_ideas = yes
		set_national_idea = yes
		national_idea_traditions = yes
		# Fresh and late-created countries begin with one slot. Capacity is
		# rebuilt from purchased idea levels below, never from the calendar.
		ve_idea_cap_effects = yes
		set_variable = ve_1936_countries
	}
	# National Identity was added after the original point-system setup. Keep
	# this outside the legacy-system guard so loading an older save initializes
	# its model and cohesion before the culture panel is evaluated.
	ve_initialize_national_identity = yes
	# Rebuild both idea progress tracks outside the legacy setup guard. Existing
	# saves keep any slot already earned because capacity only ever increases.
	ve_recalculate_national_idea_pool = yes
	national_idea_mdf = yes
}

set_point_system = {
	if = {
		limit = {
			NOT = {
				has_variable = victoria_universalis_system_on
			}
		}
		set_variable = victoria_universalis_system_on
	}
	if = {
		limit = {
			NOT = {
				has_variable = culture_reform_point
			}
		}
		set_variable = {
			name = culture_reform_point
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = piety_reform_point
			}
		}
		set_variable = {
			name = piety_reform_point
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = piety_bar_point
			}
		}
		set_variable = {
			name = piety_bar_point
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = idea_point_pool
			}
		}
		set_variable = {
			name = idea_point_pool
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = ve_splender_points
			}
		}
		set_variable = {
			name = ve_splender_points
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = ve_triggered_objectives
			}
		}
		set_variable = {
			name = ve_triggered_objectives
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = ve_age_rewards_purchased
			}
		}
		set_variable = {
			name = ve_age_rewards_purchased
			value = ve_current_age_rewards_owned
		}
	}
	if = {
		limit = {
			has_variable = clicked_golden_age
			NOT = {
				has_variable = ve_golden_age_used
			}
		}
		set_variable = ve_golden_age_used
	}
	if = {
		limit = {
			NOT = {
				has_variable = national_idea_pool
			}
		}
		set_variable = {
			name = national_idea_pool
			value = 0
		}
	}
}

set_idea_buttons = {
	if = {
		limit = {
			NOT = {
				has_variable = idea_10_bar_point
			}
		}
		set_variable = {
			name = idea_10_bar_point
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = idea_1_bar_point
			}
		}
		set_variable = {
			name = idea_1_bar_point
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = idea_2_bar_point
			}
		}
		set_variable = {
			name = idea_2_bar_point
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = idea_3_bar_point
			}
		}
		set_variable = {
			name = idea_3_bar_point
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = idea_4_bar_point
			}
		}
		set_variable = {
			name = idea_4_bar_point
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = idea_5_bar_point
			}
		}
		set_variable = {
			name = idea_5_bar_point
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = idea_6_bar_point
			}
		}
		set_variable = {
			name = idea_6_bar_point
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = idea_7_bar_point
			}
		}
		set_variable = {
			name = idea_7_bar_point
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = idea_8_bar_point
			}
		}
		set_variable = {
			name = idea_8_bar_point
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = idea_9_bar_point
			}
		}
		set_variable = {
			name = idea_9_bar_point
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = idea_11_bar_point
			}
		}
		set_variable = {
			name = idea_11_bar_point
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = idea_12_bar_point
			}
		}
		set_variable = {
			name = idea_12_bar_point
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = idea_13_bar_point
			}
		}
		set_variable = {
			name = idea_13_bar_point
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = idea_14_bar_point
			}
		}
		set_variable = {
			name = idea_14_bar_point
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = idea_15_bar_point
			}
		}
		set_variable = {
			name = idea_15_bar_point
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = idea_group_cap
			}
		}
		set_variable = {
			name = idea_group_cap
			value = 1
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = idea_group_unlocked
			}
		}
		set_variable = {
			name = idea_group_unlocked
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = unlock_an_idea_group
			}
		}
		set_variable = {
			name = unlock_an_idea_group
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = idea_point_pool
			}
		}
		set_variable = {
			name = idea_point_pool
			value = 0
		}
	}
}

set_ideas = {
	if = {
		limit = {
			NOT = {
				has_variable = academic_idea
			}
		}
		set_variable = {
			name = academic_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = agrarian_idea
			}
		}
		set_variable = {
			name = agrarian_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = financial_idea
			}
		}
		set_variable = {
			name = financial_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = infrastructure_idea
			}
		}
		set_variable = {
			name = infrastructure_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = extraction_idea
			}
		}
		set_variable = {
			name = extraction_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = mass_conscription_idea
			}
		}
		set_variable = {
			name = mass_conscription_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = war_economy_idea
			}
		}
		set_variable = {
			name = war_economy_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = industrialist_idea
			}
		}
		set_variable = {
			name = industrialist_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = bureaucratic_idea
			}
		}
		set_variable = {
			name = bureaucratic_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = nationalist_idea
			}
		}
		set_variable = {
			name = nationalist_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = parliamentary_idea
			}
		}
		set_variable = {
			name = parliamentary_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = diplomatic_idea
			}
		}
		set_variable = {
			name = diplomatic_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = mercantile_idea
			}
		}
		set_variable = {
			name = mercantile_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = welfare_idea
			}
		}
		set_variable = {
			name = welfare_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = reformist_idea
			}
		}
		set_variable = {
			name = reformist_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = labour_idea
			}
		}
		set_variable = {
			name = labour_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = offensive_idea
			}
		}
		set_variable = {
			name = offensive_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = defensive_idea
			}
		}
		set_variable = {
			name = defensive_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = naval_idea
			}
		}
		set_variable = {
			name = naval_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = professional_army_idea
			}
		}
		set_variable = {
			name = professional_army_idea
			value = 0
		}
	}
	if = {
		limit = {
			NOT = {
				has_variable = colonial_idea
			}
		}
		set_variable = {
			name = colonial_idea
			value = 0
		}
	}
}

set_national_idea = {
	# Clear the generic display marker on dedicated profiles as well. This also
	# corrects saves created before these profiles received their own icon sets.
	if = {
		limit = {
			OR = {
				AND = {
					exists = c:SPA
					this = c:SPA
				}
				AND = {
					exists = c:IBE
					this = c:IBE
				}
				AND = {
					exists = c:ITA
					this = c:ITA
				}
				AND = {
					exists = c:SWE
					this = c:SWE
				}
				AND = {
					exists = c:SCA
					this = c:SCA
				}
				AND = {
					exists = c:BIC
					this = c:BIC
				}
				AND = {
					exists = c:HND
					this = c:HND
				}
				AND = {
					exists = c:MEX
					this = c:MEX
				}
				AND = {
					exists = c:BRZ
					this = c:BRZ
				}
				AND = {
					exists = c:NET
					this = c:NET
				}
				AND = {
					exists = c:BEL
					this = c:BEL
				}
				AND = {
					exists = c:PER
					this = c:PER
				}
				AND = {
					exists = c:EGY
					this = c:EGY
				}
				AND = {
					exists = c:KOR
					this = c:KOR
				}
				AND = {
					exists = c:ARG
					this = c:ARG
				}
			}
		}
		remove_variable = generic_idea_country
	}

	# Each tag is guarded with exists: SGF, NGF and PRU are not present when this runs during
	# setup, and comparing against a country that does not exist raises
	# "Invalid right side during comparison 'c'". Same pattern the rest of this file uses.
	if = {
		limit = {
			NOR = {
				AND = {
					exists = c:GBR
					this = c:GBR
				}
				AND = {
					exists = c:FRA
					this = c:FRA
				}
				AND = {
					exists = c:GER
					this = c:GER
				}
				AND = {
					exists = c:SGF
					this = c:SGF
				}
				AND = {
					exists = c:NGF
					this = c:NGF
				}
				AND = {
					exists = c:PRU
					this = c:PRU
				}
				AND = {
					exists = c:AUS
					this = c:AUS
				}
				AND = {
					exists = c:RUS
					this = c:RUS
				}
				AND = {
					exists = c:TUR
					this = c:TUR
				}
				AND = {
					exists = c:CHI
					this = c:CHI
				}
				AND = {
					exists = c:JAP
					this = c:JAP
				}
				AND = {
					exists = c:USA
					this = c:USA
				}
				AND = {
					exists = c:SPA
					this = c:SPA
				}
				AND = {
					exists = c:IBE
					this = c:IBE
				}
				AND = {
					exists = c:ITA
					this = c:ITA
				}
				AND = {
					exists = c:SWE
					this = c:SWE
				}
				AND = {
					exists = c:SCA
					this = c:SCA
				}
				AND = {
					exists = c:BIC
					this = c:BIC
				}
				AND = {
					exists = c:HND
					this = c:HND
				}
				AND = {
					exists = c:MEX
					this = c:MEX
				}
				AND = {
					exists = c:BRZ
					this = c:BRZ
				}
				AND = {
					exists = c:NET
					this = c:NET
				}
				AND = {
					exists = c:BEL
					this = c:BEL
				}
				AND = {
					exists = c:PER
					this = c:PER
				}
				AND = {
					exists = c:EGY
					this = c:EGY
				}
				AND = {
					exists = c:KOR
					this = c:KOR
				}
				AND = {
					exists = c:ARG
					this = c:ARG
				}
			}
		}
		set_variable = generic_idea_country
	}
}


national_idea_traditions = {
	if = {
		limit = {
			exists = c:GBR
			this = c:GBR
		}
		if = {
			limit = {
				NOT = {
					has_modifier = gbr_idea_tradition_1
					has_modifier = gbr_idea_tradition_2
				}
			}
			add_modifier = {
				name = gbr_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = gbr_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:FRA
			this = c:FRA
		}
		if = {
			limit = {
				NOT = {
					has_modifier = fra_idea_tradition_1
					has_modifier = fra_idea_tradition_2
				}
			}
			add_modifier = {
				name = fra_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = fra_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:GER
			this = c:GER
		}
		if = {
			limit = {
				NOT = {
					has_modifier = ger_idea_tradition_1
					has_modifier = ger_idea_tradition_2
				}
			}
			add_modifier = {
				name = ger_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = ger_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:PRU
			this = c:PRU
		}
		if = {
			limit = {
				NOT = {
					has_modifier = ger_idea_tradition_1
					has_modifier = ger_idea_tradition_2
				}
			}
			add_modifier = {
				name = ger_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = ger_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:NGF
			this = c:NGF
		}
		if = {
			limit = {
				NOT = {
					has_modifier = ger_idea_tradition_1
					has_modifier = ger_idea_tradition_2
				}
			}
			add_modifier = {
				name = ger_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = ger_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:SGF
			this = c:SGF
		}
		if = {
			limit = {
				NOT = {
					has_modifier = ger_idea_tradition_1
					has_modifier = ger_idea_tradition_2
				}
			}
			add_modifier = {
				name = ger_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = ger_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:AUS
			this = c:AUS
		}
		if = {
			limit = {
				NOT = {
					has_modifier = aus_idea_tradition_1
					has_modifier = aus_idea_tradition_2
				}
			}
			add_modifier = {
				name = aus_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = aus_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:RUS
			this = c:RUS
		}
		if = {
			limit = {
				NOT = {
					has_modifier = rus_idea_tradition_1
					has_modifier = rus_idea_tradition_2
				}
			}
			add_modifier = {
				name = rus_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = rus_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:TUR
			this = c:TUR
		}
		if = {
			limit = {
				NOT = {
					has_modifier = tur_idea_tradition_1
					has_modifier = tur_idea_tradition_2
				}
			}
			add_modifier = {
				name = tur_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = tur_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:CHI
			this = c:CHI
		}
		if = {
			limit = {
				NOT = {
					has_modifier = qng_idea_tradition_1
					has_modifier = qng_idea_tradition_2
				}
			}
			add_modifier = {
				name = qng_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = qng_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:JAP
			this = c:JAP
		}
		if = {
			limit = {
				NOT = {
					has_modifier = jap_idea_tradition_1
					has_modifier = jap_idea_tradition_2
				}
			}
			add_modifier = {
				name = jap_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = jap_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:USA
			this = c:USA
		}
		if = {
			limit = {
				NOT = {
					has_modifier = usa_idea_tradition_1
					has_modifier = usa_idea_tradition_2
				}
			}
			add_modifier = {
				name = usa_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = usa_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:SPA
			this = c:SPA
		}
		if = {
			limit = {
				NOT = {
					has_modifier = ve_spa_idea_tradition_1
					has_modifier = ve_spa_idea_tradition_2
				}
			}
			add_modifier = {
				name = ve_spa_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = ve_spa_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:ITA
			this = c:ITA
		}
		if = {
			limit = {
				NOT = {
					has_modifier = ve_ita_idea_tradition_1
					has_modifier = ve_ita_idea_tradition_2
				}
			}
			add_modifier = {
				name = ve_ita_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = ve_ita_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:SWE
			this = c:SWE
		}
		if = {
			limit = {
				NOT = {
					has_modifier = ve_swe_idea_tradition_1
					has_modifier = ve_swe_idea_tradition_2
				}
			}
			add_modifier = {
				name = ve_swe_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = ve_swe_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:BIC
			this = c:BIC
		}
		if = {
			limit = {
				NOT = {
					has_modifier = ve_ind_idea_tradition_1
					has_modifier = ve_ind_idea_tradition_2
				}
			}
			add_modifier = {
				name = ve_ind_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = ve_ind_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:HND
			this = c:HND
		}
		if = {
			limit = {
				NOT = {
					has_modifier = ve_ind_idea_tradition_1
					has_modifier = ve_ind_idea_tradition_2
				}
			}
			add_modifier = {
				name = ve_ind_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = ve_ind_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:MEX
			this = c:MEX
		}
		if = {
			limit = {
				NOT = {
					has_modifier = ve_mex_idea_tradition_1
					has_modifier = ve_mex_idea_tradition_2
				}
			}
			add_modifier = {
				name = ve_mex_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = ve_mex_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:BRZ
			this = c:BRZ
		}
		if = {
			limit = {
				NOT = {
					has_modifier = ve_bra_idea_tradition_1
					has_modifier = ve_bra_idea_tradition_2
				}
			}
			add_modifier = {
				name = ve_bra_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = ve_bra_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:NET
			this = c:NET
		}
		if = {
			limit = {
				NOT = {
					has_modifier = ve_net_idea_tradition_1
					has_modifier = ve_net_idea_tradition_2
				}
			}
			add_modifier = {
				name = ve_net_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = ve_net_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:BEL
			this = c:BEL
		}
		if = {
			limit = {
				NOT = {
					has_modifier = ve_bel_idea_tradition_1
					has_modifier = ve_bel_idea_tradition_2
				}
			}
			add_modifier = {
				name = ve_bel_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = ve_bel_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:PER
			this = c:PER
		}
		if = {
			limit = {
				NOT = {
					has_modifier = ve_per_idea_tradition_1
					has_modifier = ve_per_idea_tradition_2
				}
			}
			add_modifier = {
				name = ve_per_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = ve_per_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:EGY
			this = c:EGY
		}
		if = {
			limit = {
				NOT = {
					has_modifier = ve_egy_idea_tradition_1
					has_modifier = ve_egy_idea_tradition_2
				}
			}
			add_modifier = {
				name = ve_egy_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = ve_egy_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:KOR
			this = c:KOR
		}
		if = {
			limit = {
				NOT = {
					has_modifier = ve_kor_idea_tradition_1
					has_modifier = ve_kor_idea_tradition_2
				}
			}
			add_modifier = {
				name = ve_kor_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = ve_kor_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:ARG
			this = c:ARG
		}
		if = {
			limit = {
				NOT = {
					has_modifier = ve_arg_idea_tradition_1
					has_modifier = ve_arg_idea_tradition_2
				}
			}
			add_modifier = {
				name = ve_arg_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = ve_arg_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:IBE
			this = c:IBE
		}
		if = {
			limit = {
				NOT = {
					has_modifier = ve_spa_idea_tradition_1
					has_modifier = ve_spa_idea_tradition_2
				}
			}
			add_modifier = {
				name = ve_spa_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = ve_spa_idea_tradition_2
				months = -1
			}
		}
	}
	else_if = {
		limit = {
			exists = c:SCA
			this = c:SCA
		}
		if = {
			limit = {
				NOT = {
					has_modifier = ve_swe_idea_tradition_1
					has_modifier = ve_swe_idea_tradition_2
				}
			}
			add_modifier = {
				name = ve_swe_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = ve_swe_idea_tradition_2
				months = -1
			}
		}
	}
	else = {
		if = {
			limit = {
				NOT = {
					has_modifier = generic_idea_tradition_1
					has_modifier = generic_idea_tradition_2
				}
			}
			add_modifier = {
				name = generic_idea_tradition_1
				months = -1
			}
			add_modifier = {
				name = generic_idea_tradition_2
				months = -1
			}
		}
	}
}

# Permanent doctrine capacity. Threshold gaps are deliberately wide enough
# that a full 1000-point Insight bank cannot normally grant two slots at once.
# Slots 5-6 belong to Age 2 and slot 7 to Age 3. Cancelling a group can reduce
# current investment but never revokes institutional capacity already earned.
ve_update_idea_group_capacity = {
	if = {
		limit = {
			NOT = { has_variable = ve_idea_capacity_progress }
		}
		set_variable = { name = ve_idea_capacity_progress value = 0 }
	}
	if = {
		limit = {
			NOT = { has_variable = idea_group_cap }
		}
		set_variable = { name = idea_group_cap value = 1 }
	}
	if = {
		limit = {
			var:idea_group_cap < 2
			var:ve_idea_capacity_progress >= 4
		}
		set_variable = { name = idea_group_cap value = 2 }
	}
	if = {
		limit = {
			var:idea_group_cap < 3
			var:ve_idea_capacity_progress >= 8
		}
		set_variable = { name = idea_group_cap value = 3 }
	}
	if = {
		limit = {
			var:idea_group_cap < 4
			var:ve_idea_capacity_progress >= 13
		}
		set_variable = { name = idea_group_cap value = 4 }
	}
	if = {
		limit = {
			var:idea_group_cap < 5
			var:ve_idea_capacity_progress >= 19
			has_global_variable = age_2_started_trigger
		}
		set_variable = { name = idea_group_cap value = 5 }
	}
	if = {
		limit = {
			var:idea_group_cap < 6
			var:ve_idea_capacity_progress >= 26
			has_global_variable = age_2_started_trigger
		}
		set_variable = { name = idea_group_cap value = 6 }
	}
	if = {
		limit = {
			var:idea_group_cap < 7
			var:ve_idea_capacity_progress >= 34
			has_global_variable = age_3_started_trigger
		}
		set_variable = { name = idea_group_cap value = 7 }
	}
}

# Compatibility name retained for yearly pulses and older scripted callers.
# Unlike the retired implementation, it contains no year-based catch-up.
ve_idea_cap_effects = {
	ve_update_idea_group_capacity = yes
}
