﻿
ig_rural_folk = {
	color = hsv{ 0.32 0.45 0.47 }
	texture = "gfx/interface/icons/ig_icons/rural_folk.dds"
	layer = "revolution_dynamic_rural_folk"
	index = 6

	ideologies = {
		ideology_agrarian
		ideology_particularist
		ideology_isolationist
	}

	character_ideologies = {
		ideology_moderate
		ideology_pacifist
	}

	enable = {
		always = yes
	}

	# Deprecated; use on_enable effect to assign traits instead
	traits = {
		ig_trait_farmers_markets
		ig_trait_honest_work
		ig_trait_old_ways
	}

	on_enable = {
		ig:ig_rural_folk ?= {
			if = {
				limit = {
					has_dlc_feature = rp1_content
					owner = { c:BRZ ?= this }
				}
				set_ig_trait = ig_trait:ig_trait_old_ways
				set_ig_trait = ig_trait:ig_trait_plantation_work
				set_ig_trait = ig_trait:ig_trait_nucleos_coloniais
			}
			else_if = {
				limit = {
					owner = { c:RUS ?= this }
				}
				set_ig_trait = ig_trait:ig_trait_old_ways
				set_ig_trait = ig_trait:ig_trait_honest_work
				set_ig_trait = ig_trait:ig_trait_obshchina
			}
			else_if = {
				limit = {
					owner = { c:EGY ?= this }
				}
				set_interest_group_name = ig_fellahin
				set_ig_trait = ig_trait:ig_trait_old_ways
				set_ig_trait = ig_trait:ig_trait_fellahin
				set_ig_trait = ig_trait:ig_trait_farmers_markets
			}
			else_if = {
				limit = {
					owner = {
						OR = {
							c:BIC ?= this
							any_primary_culture = {
								has_discrimination_trait_group = heritage_group_south_asian
								NOT = {
									has_discrimination_trait = tradition_himalayan
								}
							}
						}
					}
				}
				set_interest_group_name = ig_ryots
				set_ig_trait = ig_trait:ig_trait_of_the_sovereign_alone
				set_ig_trait = ig_trait:ig_trait_imandari
				set_ig_trait = ig_trait:ig_trait_bazaar_bargains
			}
			else_if = {
				limit = {
					owner = { c:PAN ?= this }
				}
				set_interest_group_name = ig_jats
				set_ig_trait = ig_trait:ig_trait_old_ways
				set_ig_trait = ig_trait:ig_trait_honest_work
				set_ig_trait = ig_trait:ig_trait_khalsa_panth
			}
			# Landvolk
			else_if = {
				limit = {
					has_dlc_feature = ip3_content
					owner = {
						any_primary_culture = {
							has_discrimination_trait = language_germanophone
						}
					}
				}
				set_interest_group_name = ig_landvolk
				set_ig_trait = ig_trait:ig_trait_born_particularists
				set_ig_trait = ig_trait:ig_trait_honest_work
				set_ig_trait = ig_trait:ig_trait_farmers_markets
			}
			else = {
				set_ig_trait = ig_trait:ig_trait_old_ways
				set_ig_trait = ig_trait:ig_trait_honest_work
				set_ig_trait = ig_trait:ig_trait_farmers_markets
			}
		}

		# Jeffersonian Ideology
		if = {
			limit = {
				OR = {
					country_has_primary_culture = cu:yankee
					country_has_primary_culture = cu:dixie
				}
			}
			ig:ig_rural_folk ?= {
				remove_ideology = ideology_agrarian
				add_ideology = ideology_agrarian_jeffersonian
				set_interest_group_name = ig_yeoman_farmers
			}
		}

		# Heimin
		if = {
			limit = {
				country_has_primary_culture = cu:japanese
			}
			ig:ig_rural_folk ?= {
				set_interest_group_name = ig_peasants
			}
		}
		# Maka'āinana
		if = {
			limit = {
				country_has_primary_culture = cu:hawaiian
			}
			ig:ig_rural_folk ?= {
				set_interest_group_name = ig_maka_ainana
			}
		}
		# Sikh Empire
		if = {
			limit = {
				c:PAN ?= this
			}
			ig:ig_rural_folk ?= {
				set_interest_group_name = ig_jats
			}
		}
		# India
		else_if = {
			limit = {
				OR = {
					c:BIC ?= this
					any_primary_culture = {
						has_discrimination_trait_group = heritage_group_south_asian
						NOT = {
							has_discrimination_trait = tradition_himalayan
						}
					}
				}
			}
			ig:ig_rural_folk ?= {
				set_interest_group_name = ig_ryots
			}
		}
		# Nepal
		else_if = {
			limit = {
				any_primary_culture = {
					has_discrimination_trait_group = heritage_group_south_asian
					has_discrimination_trait = tradition_himalayan
				}
			}
			ig:ig_rural_folk ?= {
				set_interest_group_name = ig_kisanharu
			}
		}
	}
	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 lacustrine_bantu oromo
			}
		}
	}
	on_character_ig_membership = {
		if = {
			limit = {
				OR = {
					culture = cu:oromo
					culture = cu:lacustrine_bantu
				}
				owner = {
					c:ZAN ?= this
					any_primary_culture = {
						cu:bedouin = this
					}
				}
			}
			random_list = {
				2 = { change_character_religion = rel:sunni }
				1 = { change_character_religion = rel:animist }
			}
		}
	}

	pop_potential = {
		NOT = {
			is_pop_type = capitalists
		}
		OR = {
			rural_employment = yes
			is_pop_type = peasants	
			is_pop_type = aristocrats
		}
	}

	pop_weight = {
		value = 0

		add = {
			desc = "RURAL_POP"
			if = {
				limit = { 
					NOR = {
						is_pop_type = aristocrats
						is_pop_type = clergymen
					}
					rural_employment = yes
				}
				value = 50
			}
		}

		add = {
			desc = "POP_FARMERS"
			if = {
				limit = {
					is_pop_type = farmers
				}
				value = 250
			}
		}

		add = {
			desc = "POP_PEASANTS"
			if = {
				limit = {
					is_pop_type = peasants
				}
				value = 250
			}
		}

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

		add = {
			desc = "POP_CLERGYMEN"
			if = {
				limit = {
					is_pop_type = clergymen
					owner = {
						ig:ig_devout = {
							leader = {
								has_ideology = ideology:ideology_legitimist
							}
						}
					}
				}
				value = 150
			}
		}
		
		if = {
			limit = {
				c:BIC ?= owner
				culture = {
					has_discrimination_trait_group = heritage_group_european
				}
			}
			multiply = {
				desc = "POP_INDIA_COLONIAL_RULE"
				value = 0.1
			}
		}
	
		
		add = {
			desc = "RURAL_POP"
			if = {
				limit = { 
					is_pop_type = clergymen
					rural_employment = yes
				}
				value = 25
			}
		}

		add = {
			desc = "POP_ARISTOCRATS"
			if = {
				limit = { 
					is_pop_type = aristocrats
				}
				value = 5
			}
		}
		
		add = {
			desc = "ideology_jacksonian_democrat"
			if = {
				limit = {
					owner = {
						ig:ig_rural_folk = {
							leader = {
								has_ideology = ideology:ideology_jacksonian_democrat
							}
						}
					}
					OR = {
						is_pop_type = farmers
						is_pop_type = peasants
						is_pop_type = clergymen
						is_pop_type = aristocrats
					}
				}
				value = 200
			}
		}

		add = {
			desc = "DIXIE"
			if = {
				limit = { 
					owner = {
						c:USA = THIS
					}
					owner = {
						ig:ig_rural_folk = {
							leader = {
								NOT = {has_ideology = ideology:ideology_jacksonian_democrat}
							}
						}
					}
					OR = {
						rural_employment = yes
						is_pop_type = peasants
					}
					NOT = {is_pop_type = laborers}
					culture = cu:dixie
				}
				value = -200
			}
		}

		add = {
			desc = "NON_SLAVE_STATE"
			if = {
				limit = {
					is_pop_type = aristocrats
					owner = {
						THIS = c:USA
						ig:ig_landowners = {
							has_ideology = ideology:ideology_pro_slavery
						}
					}
					state = { 
						is_slave_state = no
					}
				}
				value = 200
			}
		}

		multiply = { #Pops are less attracted to radical ideologies if they're not poor
			desc = "Radical Leader Ideology"
			value = 1.0
			if = {
				limit = {
					owner = {					
						ig:ig_rural_folk = {
							leader = {
								OR = {
									has_ideology = ideology:ideology_vanguardist
									has_ideology = ideology:ideology_anarchist
									has_ideology = ideology:ideology_communist
									has_ideology = ideology:ideology_radical
								}
							}
						}
						NAND = {
							OR = {
								has_law = law_type:law_council_republic
								has_law = law_type:law_autocracy
							}
							ig:ig_rural_folk = {
								is_in_government = yes
							}
						}						
					}
					NOT = {
						standard_of_living <= 20
					}
				}
				value = 0.75
			}
		}

		multiply = { #Pops are less attracted to radical ideologies if they're not poor
			desc = "Radical Leader Ideology"
			value = 1.0
			if = {
				limit = {
					owner = {					
						ig:ig_rural_folk = {
							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 Ideology"
			value = 1.0
			if = {
				limit = {
					owner = {					
						ig:ig_rural_folk = {
							leader = {
								has_ideology = ideology:ideology_communist
							}
						}						
					}
					NOT = {
						standard_of_living <= 20
					}
				}
				value = 0.75
			}
		}

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

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

		multiply = {
			desc = "law_command_economy"
			value = 1.0
			if = {
				limit = {
					owner = {
						has_law = law_type:law_command_economy
					}
				}
				value = 1.2
			}
		}

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

		multiply = {
			desc = "MONARCHIST"
			value = 1.0

			if = {
				limit = {
					owner = {
						OR = {
							any_interest_group = {
								is_interest_group_type = ig_landowners
								is_marginal = no
							}
							any_interest_group = {
								is_interest_group_type = ig_devout
								is_marginal = no
							}
						}
						has_law = law_type:law_monarchy 
					}
					NOT = { pop_employment_building_group = bg_logging }
					pop_acceptance >= acceptance_status_3
					has_state_religion = yes
					NOT = { is_pop_type = aristocrats }
					NOT = { #orleanists are too economicaly liberals
						owner = {
							ig:ig_landowners = {
								leader = {
									has_ideology = ideology:ideology_orleanist
								}
							}
						}
					}
				}
				value = 0.75
			}
		}

		multiply = {
			desc = "ideology_bonapartist"
			value = 1.0

			if = {
				limit = {
					owner = {
						has_law = law_type:law_monarchy
						ig:ig_petty_bourgeoisie = {
							leader = {
								has_ideology = ideology:ideology_bonapartist
							}
						}
					}
					pop_acceptance >= acceptance_status_3
				}
				value = 0.75
			}
		}		
		
		multiply = {
			desc = "ideology_bonapartist"
			value = 1.0

			if = {
				limit = {
					owner = {
						NOT = { has_law = law_type:law_monarchy }
						ig:ig_petty_bourgeoisie = {
							leader = {
								has_ideology = ideology:ideology_bonapartist
							}
						}
					}
					pop_acceptance >= acceptance_status_3
				}
				value = 0.50
			}
		}		

		multiply = {
			desc = "THEOCRACT"
			value = 1.0

			if = {
				limit = {
					owner = {
						any_interest_group = {
							is_interest_group_type = ig_devout
							is_marginal = no
						}
						has_law = law_type:law_theocracy 
					}
					NOT = { pop_employment_building_group = bg_logging }
					pop_has_primary_culture = yes
					has_state_religion = yes
				}
				value = 0.25
			}
		}

		multiply = {
			desc = "LEFTRURALS"
			value = 1.0

			if = {
				limit = {
					owner = {
						any_interest_group = { 
							is_interest_group_type = ig_rural_folk 
							leader = {
								OR = {
									has_ideology = ideology:ideology_nihilist
									has_ideology = ideology:ideology_communist
									has_ideology = ideology:ideology_vanguardist
									has_ideology = ideology:ideology_anarchist
									has_ideology = ideology:ideology_radical
								}
							}
						}
					}
					is_pop_type = aristocrats
				}
				value = 0
			}
		}

		multiply = {
			desc = "LEFTRURALS"
			value = 1.0

			if = {
				limit = {
					owner = {
						any_interest_group = { 
							is_interest_group_type = ig_rural_folk 
							leader = {
								OR = {
									has_ideology = ideology:ideology_nihilist
									has_ideology = ideology:ideology_communist
									has_ideology = ideology:ideology_vanguardist
									has_ideology = ideology:ideology_anarchist
									has_ideology = ideology:ideology_radical
								}
							}
						}
					}
					OR = {
						is_pop_type = clergymen
						is_pop_type = farmers
					}
				}
				value = 0.25
			}
		}

		add = {
			desc = "concept_literacy"
			
			if = {
				limit = { 
					literacy_rate >= 0.50
					NOR = { 
						is_pop_type = clergymen
						is_pop_type = aristocrats
					}
				}
				value = literacy_rate
				subtract = 0.5
				multiply = -50
				min = -25
			}
		}
		
		add = {
			desc = "WEALTH"
			if = {
				limit = { 
					rural_employment = yes
					strata = poor
					wealth < 15
				}
				value = wealth
				subtract = 15
				multiply = -5
				max = 50
			}
		}

		add = {
			desc = "RESOURCE_POP"
			if = {
				limit = { 
					NOR = {
						is_pop_type = aristocrats
						is_pop_type = clergymen
					}
					OR = {
						pop_employment_building_group = bg_mining
						pop_employment_building_group = bg_oil_extraction				
					}
				}
				value = 25
			}
		}


		multiply = {
			desc = "SMALL_URBAN_CENTER"
			value = 1.0
			if = {
				limit = {
					state = {
						any_scope_building = {
							is_building_type = building_urban_center
							level < 5
						}
					}
				}
				value = 1.25
			}
		}	

		multiply = {
			desc = "NO_URBAN_CENTER"
			value = 1.0
			if = {
				limit = {
					state = {
						NOT = {
							any_scope_building = {
								is_building_type = building_urban_center
							}
						}
					}
				}
				value = 1.5
			}
		}

		multiply = {
			desc = "geographic_region_europe"
			value = 1.0
			if = {
				limit = {
					state = {
						is_in_geographic_region = geographic_region_europe
					}
				}
				value = 0.5
			}
		}
		
		multiply = {
			desc = "LEADER_POPULARITY"
			scope:interest_group ?= {
				leader ?= {
					value = popularity
					multiply = 0.0025
					add = 1
					max = 1.25
					min = 0.75
				}
			}
		}
		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
			}
		}
		
		multiply = {
			desc = "IG_IS_MARGINALIZED"
			value = 1.0
			
			scope:interest_group ?= {
				if = {
					limit = {
						ig_counts_as_marginal = yes
					}
					value = 0.75
				}
			}
		}	
	}

	monarch_weight = {
		value = 0.25 # this is just inherently unlikely
		# 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
			}
		}
		# More likely with Homesteading
		if = {
			limit = {
				owner = {
					has_law_or_variant = law_type:law_peasant_proprietorship
				}
			}
			multiply = {
				value = 2
			}
		}
		# Impossible with Serfdom
		if = {
			limit = {
				owner = {
					has_law_or_variant = law_type:law_serfdom
				}
			}
			multiply = {
				value = 0
			}
		}
	}

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

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

	executive_weight = {
		value = 0.1

		# 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.2
	}

	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.025
			}
		}
	}

	female_agitator_chance = {
		value = 0.025

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

			}
			add = {
				value = 0.025
			}
		}

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

			}
			add = {
				value = 0.025
			}
		}

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

			}
			add = {
				value = 0.025
			}
		}
	}

	# 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.75
	}

	# 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.25
		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.1
	}
}
