﻿ig_intelligentsia = {
	color = hsv{ 0.13 0.64 0.99 }
	texture = "gfx/interface/icons/ig_icons/intelligensia.dds"
	layer = "revolution_dynamic_intelligentsia"
	index = 3

	ideologies = {
		ideology_liberal
		ideology_anti_clerical
		ideology_republican
		ideology_anti_slavery
	}

	character_ideologies = {
		ideology_moderate
		ideology_republican_leader
		ideology_radical
		ideology_reformer
		ideology_sovereignist_leader
		ideology_despotic_utopian
		ideology_humanitarian
		ideology_utopian
	}

	enable = {
		always = yes
	}

	# Deprecated; use on_enable effect to assign traits instead
	traits = {
		ig_trait_propagandists
		ig_trait_avant_garde
		ig_trait_social_criticism
	}

	on_enable = {
		ig:ig_intelligentsia ?= {
			### Specific IG traits
			if = {
				limit = {
					owner = { c:CHI ?= this }
				}
				set_ig_trait = ig_trait:ig_trait_social_criticism
				set_ig_trait = ig_trait:ig_trait_avant_garde
				set_ig_trait = ig_trait:ig_trait_restoration
			}
			else_if = {
				limit = {
					owner = {
						OR = {
							c:TUR ?= this
							c:RUS ?= this
						}
					}
				}
				set_ig_trait = ig_trait:ig_trait_crisis_of_identity
				set_ig_trait = ig_trait:ig_trait_avant_garde
				set_ig_trait = ig_trait:ig_trait_propagandists
			}
			else_if = {
				limit = {
					has_dlc_feature = voice_of_the_people_content
					owner = { c:FRA ?= this }
				}
				set_ig_trait = ig_trait:ig_trait_social_criticism
				set_ig_trait = ig_trait:ig_trait_avant_garde
				set_ig_trait = ig_trait:ig_trait_les_beaux_arts
			}
			else_if = {
				limit = {
					has_dlc_feature = ip2_content
					owner = { c:BIC ?= this }
				}
				set_ig_trait = ig_trait:ig_trait_swaraj
				set_ig_trait = ig_trait:ig_trait_civil_service
				set_ig_trait = ig_trait:ig_trait_westernisation
			}
			else = {
				set_ig_trait = ig_trait:ig_trait_social_criticism
				set_ig_trait = ig_trait:ig_trait_avant_garde
				set_ig_trait = ig_trait:ig_trait_propagandists
			}
		}
		# Papal Intellegentsia
		if = {
			limit = {
				c:PAP ?= this
			}
			ig:ig_intelligentsia ?= {
				remove_ideology = ideology_anti_clerical
			}
		}
		# Hawaiian Democrats
		else_if = {
			limit = {
				country_has_primary_culture = cu:hawaiian
			}
			ig:ig_intelligentsia ?= {
				set_interest_group_name = ig_hawaiian_democrats
			}
		}
		# Literati
		else_if = {
			limit = {
				any_primary_culture = {
					has_discrimination_trait = heritage_han
				}
			}
			ig:ig_intelligentsia ?= {
				set_interest_group_name = ig_literati
				remove_ideology = ideology_anti_clerical
			}
		}
		# Brazilian Intelligentsia
		else_if = {
			limit = {
				has_dlc_feature = rp1_content
				c:BRZ ?= THIS
			}
			ig:ig_intelligentsia ?= {
				set_ig_trait = ig_trait:ig_trait_brasilidade
				set_ig_trait = ig_trait:ig_trait_bachareis
				set_ig_trait = ig_trait:ig_trait_social_criticism

				remove_ideology = ideology_republican
				add_ideology = ideology_constitutionalist
			}
		}
		# Philippines Intelligentsia
		else_if = {
			limit = {
				c:PHI ?= this
			}
			ig:ig_intelligentsia ?= {
				set_interest_group_name = ig_ilustrados
			}
		}
		# India
		else_if = {
			limit = {
				c:BIC ?= THIS
			}
			ig:ig_intelligentsia ?= {
				set_interest_group_name = ig_civil_servants

				remove_ideology = ideology_republican
				add_ideology = ideology_constitutionalist
			}
		}
		# Britain and other Constitutionalists
		if = {
			limit = {
				OR = {
					c:GBR ?= THIS
					c:POR ?= THIS
					c:SPA ?= THIS
					c:AUS ?= THIS
					any_primary_culture = { # Princely States and Nepal
						has_discrimination_trait_group = heritage_group_south_asian
					}
				}
			}
			ig:ig_intelligentsia ?= {
				remove_ideology = ideology_republican
				add_ideology = ideology_constitutionalist
			}
		}
		if = {
			limit = {
				country_has_primary_culture = cu:japanese
			}
			ig:ig_intelligentsia ?= {
				set_interest_group_name = ig_rangakusha
				remove_ideology = ideology_republican
				add_ideology = ideology_rangaku
			}
		}
		if = {
			limit = {
				has_technology_researched = feminism
			}
			every_interest_group = {
				limit = {
					has_ideology = ideology:ideology_liberal
				}
				remove_ideology = ideology_liberal
				add_ideology = ideology_liberal_modern
			}
		}
	}
	on_disable = {}
	priority_cultures = { #Country scope
		rule = {
			trigger = {
				c:BIC ?= this
				any_primary_culture = {
					cu:british = this
				}
			}
			cultures = {
				assamese avadhi baluchi bengali bihari gujarati kannada malayalam marathi oriya panjabi pathan rajput sindi tamil telegu hindustani bundeli pahari gondi bageli chhattisgarhi deccani
			}
		}
		rule = {
			trigger = {
				c:ZAN ?= this
				any_primary_culture = {
					cu:bedouin = this
				}
			}
			cultures = {
				swahili bedouin
			}
		}
		rule = {
			trigger = {
				c:PHI ?= this
				NOT = { has_variable = je_philippines_main_reliance_happened }
				NOT = { any_primary_culture = { cu:filipino = this } }
				NOT = { any_primary_culture = { cu:filipino_hispanophone = this } }
				any_primary_culture = { cu:spanish = this }
			}
			cultures = {
				spanish filipino_mestizo
			}
		}
		rule = {
			trigger = {
				c:PHI ?= this
				any_primary_culture = {
					AND = {
						cu:spanish = this
						cu:filipino_hispanophone = this
					}
				}
			}
			cultures = {
				spanish filipino_hispanophone
			}
		}
	}
	on_character_ig_membership = {}

	pop_potential = {
		literacy_rate > 0.25
		OR = {
			is_pop_type = academics
			is_pop_type = aristocrats
			is_pop_type = bureaucrats
			is_pop_type = capitalists
			is_pop_type = clergymen
			is_pop_type = clerks
			is_pop_type = engineers
			is_pop_type = laborers
			is_pop_type = machinists
		}
	}

	pop_weight = {
		value = 0

		add = {
			desc = "POP_ACADEMICS"
			if = {
				limit = {
					is_pop_type = academics
				}
				value = 250
			}
		}

		add = {
			desc = "POP_BUREAUCRATS"
			if = {
				limit = {
					is_pop_type = bureaucrats
				}
				value = 150
			}
		}

		add = {
			desc = "POP_CLERKS"
			if = {
				limit = {
					is_pop_type = clerks
				}
				value = 100
			}
		}

		add = {
			desc = "POP_CAPITALISTS"
			if = {
				limit = {
					is_pop_type = capitalists
					owner = {
						NOT = {country_has_primary_culture = cu:french}
					}
				}
				value = 50
			}
			else_if = {
				limit = {
					is_pop_type = capitalists
					owner = {
						country_has_primary_culture = cu:french
					}
				}
				value = 75
			}
		}

		add = {
			desc = "POP_ARISTOCRATS"
			if = {
				limit = {
					is_pop_type = aristocrats
					owner = {
						has_technology_researched = academia
					}
				}
				if = {
					limit = {
						owner = {
							has_law_or_variant = law_type:law_hereditary_bureaucrats
						}
					}
					value = 100
				}
				else_if = {
					limit = {
						owner = {
							country_has_primary_culture = cu:french
						}
					}
					value = 75
				}
				else = {
					value = 50
				}
			}
		}

		add = {
			desc = "je_hungarian_revolution"
			if = {
				limit = {
					is_pop_type = aristocrats
					culture = cu:hungarian
					owner ?= {
						has_journal_entry = je_hungarian_revolution
					}
				}
				value = 50
			}
		}

		add = {
			desc = "POP_UNRECOGNIZED"
			if = {
				limit = {
					is_pop_type = aristocrats
					owner = {
						is_country_type = unrecognized
					}
				}
				value = 25
			}
		}
		
		add = {
			desc = "ADMINISTRATION_ROLE"
			if = {
				limit = {
					OR = {
						is_pop_type = aristocrats
						is_pop_type = clergymen
						is_pop_type = capitalists
					}
					OR = {
						pop_employment_building_group = bg_service
						pop_employment_building_group = bg_arts
						pop_employment_building_group = bg_government
						pop_employment_building_group = bg_private_infrastructure
						#pop_employment_building_group = bg_financial_districts
					}
				}
				value = 100
			}
		}

		if = {
			limit = {
				owner = {
					c:BIC ?= this
				}
				OR = {
					is_pop_type = bureaucrats
					is_pop_type = clerks
				}
			}
			if = {
				limit = {
					culture = {
						has_discrimination_trait_group = heritage_group_european
					}
				}
				multiply = {
					desc = "POP_INDIA_COLONIAL_RULE"
					value = 0.25
				}
			}
			else = {
				multiply = {
					desc = "POP_INDIA_CIVIL_SERVICE"
					value = 1.5
				}
			}
		}

		add = {
			desc = "POP_MILITARY_BUREAUCRACY"
			if = {
				limit = {
					is_pop_type = bureaucrats
					owner = {
						c:ALK ?= this
						has_government_type = gov_chartered_company
					}
				}
				multiply = 0.25
			}
		}

		if = {
			limit = {
				literacy_rate >= 0.50
				NOR = { 
					is_pop_type = clergymen
					is_pop_type = aristocrats
					is_pop_type = capitalists
				}
			}
			add = {
				desc = "POP_LITERACY"
				value = literacy_rate
				multiply = 20
			}
		}
		
		multiply = {
			desc = "POP_LITERACY"
			value = 1.0
			
			if = {
				limit = { 
					literacy_rate < 0.5
					literacy_rate > 0.25
				}
				value = literacy_rate
				multiply = 2
			}
		}

		multiply = {
			desc = "POP_LITERACY"
			value = 1.0
			
			if = {
				limit = { 
					literacy_rate < 0.25
				}
				value = literacy_rate
			}
		}

		multiply = {
			desc = "RURAL_POP"
			value = 1.0
			
			if = {
				limit = { 
					rural_employment = yes
				}
				value = 0.75
			}
		}
		
		add = {
			desc = "POP_ENGINEERS"
			if = {
				limit = { 
					is_pop_type = engineers
				}
				value = 100
			}
		}

		add = {
			desc = "POP_OFFICERS"
			if = {
				limit = { 
					is_pop_type = officers
				}
				value = 50
			}
		}

		add = {
			desc = "POP_CLERGYMEN"
			if = {
				limit = { 
					is_pop_type = clergymen
				}
				value = 50
				if = {
					limit = {
						owner = {
							ig:ig_devout = {
								leader = {
									has_ideology = ideology:ideology_legitimist
								}
							}
						}
					}
					add = 100
				}
			}
		}

		add = {
			desc = "POP_MACHINISTS"
			if = {
				limit = { 
					is_pop_type = machinists
				}
				value = 25
			}
		}

		add = {
			desc = "JAPAN_IMPERIALIST"
			if = {
				limit = {
					is_pop_type = aristocrats
					owner = {
						ig:ig_intelligentsia = {
							has_ideology = ideology:ideology_japanese_imperialist
						}
					}
				}
				value = 50
			}
		}
		
		add = {
			desc = "ideology_junker_paternalistic"
			if = {
				limit = { 
					OR = {
						is_pop_type = aristocrats
						is_pop_type = capitalists
					}
					has_state_religion = yes
					religion = rel:protestant
					owner = {
						ig:ig_landowners = {
							has_ideology = ideology:ideology_junker_paternalistic
						}
					}
				}
				value = -25
			}
		}

		add = {
			desc = "ideology_junker_paternalistic"
			if = {
				limit = { 
					is_pop_type = bureaucrats
					has_state_religion = yes
					religion = rel:protestant
					owner = {
						ig:ig_landowners = {
							has_ideology = ideology:ideology_junker_paternalistic
						}
					}
				}
				value = -100
			}
		}
		

		multiply = { #Pops are less attracted to radical ideologies if they're not poor
			desc = "RADICAL_LEADER"
			value = 1.0
			if = {
				limit = {
					owner = {					
						ig:ig_intelligentsia = {
							leader = {
								has_ideology = ideology:ideology_vanguardist
							}
						}						
					}
					NOT = {
						standard_of_living <= 20
					}
				}
				value = 0.75
			}
		}

		multiply = { #Pops are less attracted to radical ideologies if they're not poor
			desc = "RADICAL_LEADER"
			value = 1.0
			if = {
				limit = {
					owner = {					
						ig:ig_intelligentsia = {
							leader = {
								has_ideology = ideology:ideology_anarchist
							}
						}						
					}
					NOT = {
						standard_of_living <= 20
					}
				}
				value = 0.75
			}
		}

		multiply = { #Pops are less attracted to radical ideologies if they're not poor
			desc = "RADICAL_LEADER"
			value = 1.0
			if = {
				limit = {
					owner = {					
						ig:ig_intelligentsia = {
							leader = {
								has_ideology = ideology:ideology_communist
							}
						}						
					}
					NOT = {
						standard_of_living <= 20
					}
				}
				value = 0.75
			}
		}

		multiply = {
			desc = "law_autocracy"
			value = 1.0
			if = {
				limit = {
					owner = {
						has_law = law_type:law_autocracy
					}
				}
				value = 1.5
			}
		}

		multiply = {
			desc = "law_oligarchy"
			value = 1.0
			if = {
				limit = {
					owner = {
						has_law = law_type:law_oligarchy
					}
				}
				value = 1.3
			}
		}

		multiply = {
			desc = "law_landed_voting"
			value = 1.0
			if = {
				limit = {
					owner = {
						has_law = law_type:law_landed_voting
					}
				}
				value = 1.25
			}
		}

		multiply = {
			desc = "law_wealth_voting"
			value = 1.0
			if = {
				limit = {
					owner = {
						has_law = law_type:law_wealth_voting
					}
				}
				value = 1.15
			}
		}

		multiply = {
			desc = "law_census_voting"
			value = 1.0
			if = {
				limit = {
					owner = {
						has_law = law_type:law_census_voting
					}
				}
				value = 1.1
			}
		}

		multiply = {
			desc = "law_anarchy"
			value = 1.0
			if = {
				limit = {
					owner = {
						has_law = law_type:law_anarchy
					}
				}
				value = 1.1
			}
		}

		multiply = {
			desc = "law_outlawed_dissent"
			value = 1.0
			if = {
				limit = {
					owner = {
						has_law = law_type:law_outlawed_dissent
					}
				}
				value = 1.5
			}
		}

		multiply = {
			desc = "law_censorship"
			value = 1.0
			if = {
				limit = {
					owner = {
						has_law = law_type:law_censorship
					}
				}
				value = 1.25
			}
		}

		multiply = {
			desc = "law_state_religion"
			value = 1.0
			if = {
				limit = {
					owner = {
						has_law = law_type:law_state_religion
					}
				}
				value = 1.25
			}
		}

		multiply = {
			desc = "law_no_schools"
			value = 1.0
			if = {
				limit = {
					owner = {
						has_law = law_type:law_no_schools
					}
				}
				value = 1.5
			}
		}

		multiply = {
			desc = "law_debt_slavery"
			value = 1.0
			if = {
				limit = {
					owner = {
						has_law = law_type:law_debt_slavery
					}
				}
				value = 1.5
			}
		}

		multiply = {
			desc = "law_slave_trade"
			value = 1.0
			if = {
				limit = {
					owner = {
						has_law = law_type:law_slave_trade
					}
				}
				value = 1.5
			}
		}

		multiply = {
			desc = "law_legacy_slavery"
			value = 1.0
			if = {
				limit = {
					owner = {
						has_law = law_type:law_legacy_slavery
					}
				}
				value = 1.25
			}
		}

		add = { #Some Pops that would support TU supports Intelligentsia instead
			desc = "NO_LABOR_MOVEMENT"
			if = {
				limit = { 
					OR = {
						is_pop_type = laborers
						is_pop_type = machinists
					}
					owner = {
						NOT = { has_technology_researched = labor_movement }
					}
				}
				value = 50
			}
		}
		
		add = { #Some Pops that would support TU supports Intelligentsia instead
			desc = "NO_EGALITARIANISM"
			if = {
				limit = { 
					OR = {
						is_pop_type = laborers
						is_pop_type = machinists
					}
					owner = {
						NOT = { has_technology_researched = egalitarianism }
					}
				}
				value = 25
			}
		}

		add = { #Some Pops that would support TU supports Intelligentsia instead
			desc = "NO_SOCIALISM"
			if = {
				limit = { 
					OR = {
						is_pop_type = laborers
						is_pop_type = machinists
					}
					owner = {
						NOT = { has_technology_researched = socialism }
					}
				}
				value = 50
			}
		}

		multiply = {
			desc = "AFROAMERICAN"
			value = 1.0

			if = {
				limit = {
					owner = {
						c:USA = THIS
					}
					culture = cu:afro_american
				}
				value = 2
			}
		}

		multiply = {
			desc = "LEFTISTINTELLIGENTSIA"
			value = 1.0

			if = {
				limit = {
					owner = {
						any_interest_group = { 
							is_interest_group_type = ig_intelligentsia 
							leader = {
								OR = {
									has_ideology = ideology:ideology_communist
									has_ideology = ideology:ideology_vanguardist
									has_ideology = ideology:ideology_anarchist
								}
							}
						}
					}
					OR = {
						is_pop_type = aristocrats
						is_pop_type = capitalists
					}
				}
				value = 0.1
			}
		}

		multiply = {
			desc = "ideology_jacksonian_democrat"
			value = 1.0
			if = {
				limit = {
					owner = {
						ig:ig_rural_folk = {
							leader = {
								has_ideology = ideology:ideology_jacksonian_democrat
							}
						}
					}
				}
				value = 0.75
			}
		}

		multiply = {
			desc = "ideology_revolutionary_republican"
			value = 1.0
			if = {
				limit = {
					NOR = {
						is_pop_type = aristocrats
						is_pop_type = capitalists
						is_pop_type = clergymen
					}
					owner = {
						country_has_primary_culture = cu:french
						NOT = { has_technology_researched = socialism }
					}
				}
				value = 2
			}
		}

		multiply = {
			desc = "IG_IS_MARGINALIZED"
			value = 1.0
			
			scope:interest_group = {
				if = {
					limit = {
						ig_counts_as_marginal = yes
					}
					value = 0.75
				}
			}
		}
		multiply = {
			desc = "LEADER_POPULARITY"
			scope:interest_group = {
				leader ?= {
					value = popularity
					multiply = 0.0025
					add = 1
					max = 1.25
					min = 0.75
				}
			}
		}

		multiply = {
			desc = "decentralized_power"
			value = 1.0

			if = {
				limit = {
					owner = {
						is_country_type = decentralized
					}
				}
				value = 0.0
			}
		}
		if = {
			limit = {
				scope:interest_group = {
					is_in_government = yes
				}
			}
			multiply = {
				desc = "IN_GOVERNMENT_ATTRACTION"
				value = 1
				add = scope:interest_group.modifier:interest_group_in_government_attraction_mult
				min = 0
			}
		}

		if = {
			limit = {
				scope:interest_group = {
					is_in_government = yes
				}
			}
			multiply = { # Multiplied by 1.25x max
				desc = "POP_LOYALISTS"
				value = pop_loyalist_fraction
				divide = 4
				add = 1
			}
		}
		if = {
			limit = {
				scope:interest_group = {
					is_in_government = no
				}
			}
			multiply = { # Multiplied by 1.25x max
				desc = "POP_RADICALS"
				value = pop_radical_fraction
				divide = 4
				add = 1
			}
		}
	}

	monarch_weight = {
		value = 1
		# Monarch is not likely to adopt a marginal IG
		if = {
			limit = {
				ig_counts_as_marginal = yes
			}
			multiply = {
				value = 0.1
			}
		}
		# Monarch is more likely to adopt a Powerful IG
		if = {
			limit = {
				is_powerful = yes
			}
			multiply = {
				value = 2
			}
		}
		# Much more likely with Technocracy
		if = {
			limit = {
				owner = {
					has_law_or_variant = law_type:law_technocracy
				}
			}
			multiply = {
				value = 3
			}
		}
		# More likely with Appointed Bureaucrats
		if = {
			limit = {
				owner = {
					has_law_or_variant = law_type:law_appointed_bureaucrats
				}
			}
			multiply = {
				value = 1.5
			}
		}
		# Impossible without Empiricism
		if = {
			limit = {
				owner = {
					NOT = { has_technology_researched = empiricism }
				}
			}
			multiply = {
				value = 0
			}
		}
	}

	agitator_weight = {
		# Agitators more likely to come from populist IG's rather than elitist
		value = 0.75
		# Agitators will never be part of a marginalized IG
		if = {
			limit = {
				owner.ig:ig_intelligentsia ?= {
					ig_counts_as_marginal = yes
				}
			}
			multiply = {
				value = 0
			}
		}
	}

	commander_weight = {
		value = 1.0
	}
	
	magnate_weight = {
		value = 1.0
	}	

	executive_weight = {
		value = 2.0

		# The company owning BIC should not get non-industrialist executives
		if = {
			limit = {
				exists = scope:company
				exists = c:BIC
				c:BIC ?= {
					exists = owning_company
					owning_company = scope:company
				}
			}
			multiply = {
				value = 0
			}
		}
	}

	noble_chance = {
		value = 0.5
	}

	female_commander_chance = {
		value = 0.0
	}

	female_executive_chance = {
		value = 0.0
	}

	female_monarch_chance = {
		value = 0.025
	}

	female_politician_chance = {
		value = 0.0


		if = {
			limit = {
				owner = {
					has_law_or_variant = law_type:law_womens_suffrage
				}
				law_stance = {
					law = law_type:law_womens_suffrage
					value >= approve
				}
			}
			add = {
				value = 0.05
			}
		}
	}

	female_agitator_chance = {
		value = 0.035

		if = {
			limit = {
				owner = {
					has_law_or_variant = law_type:law_women_own_property
				}

			}
			add = {
				value = 0.035
			}
		}

		if = {
			limit = {
				owner = {
					has_law_or_variant = law_type:law_women_in_the_workplace
				}

			}
			add = {
				value = 0.035
			}
		}

		if = {
			limit = {
				owner = {
					has_law_or_variant = law_type:law_womens_suffrage
				}

			}
			add = {
				value = 0.035
			}
		}
	}

	# Multiplier applied to the weight for an appropriate commander will be selected from the character pool to lead the IG
	# root = interest group
	commander_leader_weight = {
		value = 0.5
	}
	
	# Multiplier applied to the weight for an appropriate magnate will be selected from the character pool to lead the IG
	# root = interest group
	magnate_leader_weight = {
		value = 0.5
		if = {
			limit = {
				c:JAP ?= owner
				NOT = {
					has_variable = japan_restoration_complete
				}
			}
			add = 5
		}
	}	

	# Multiplier applied to the weight for an appropriate executive will be selected from the character pool to lead the IG
	# root = interest group
	executive_leader_weight = {
		value = 0.5
	}
}
