﻿##############################VANILLA##############################

# Peruvian Amazon Company
TRY_REPLACE:company_peruvian_amazon = {
	icon = "gfx/interface/icons/company_icons/historical_company_icons/peru_peruvian_amazon_company.dds"
	background = "gfx/interface/icons/company_icons/company_backgrounds/comp_illu_plantation.dds"

	flavored_company = yes

	preferred_headquarters = { STATE_PASTAZA }
	
	possible_prestige_goods = {
		prestige_good_amazonian_rubber
	}

	building_types = {
		building_rubber_plantation
	}

	extension_building_types = {
		building_logging_camp
	}

	potential = {
		has_interest_marker_in_region = sr:region_andes
	}

	attainable = {
		hidden_trigger = { # Hide attainable if it's always fulfilled by possible
			any_scope_state = {
				state_region = s:STATE_PASTAZA
			}
		}
	}

	possible = {
		has_technology_researched = rubber_mastication
		any_scope_state = {
			state_region = s:STATE_PASTAZA
			any_scope_building = {
				is_building_type = building_rubber_plantation
				level >= 5
			}
		}
	}

	prosperity_modifier = {
		state_loyalists_from_political_movements_mult = 0.1
		building_group_bg_rubber_mortality_mult = 0.1
	}

	ai_will_do = {
		has_technology_researched = rubber_mastication
		any_scope_state = {
			state_region = s:STATE_PASTAZA
			is_incorporated = yes
		}
	}

	ai_construction_targets = {
		building_rubber_plantation = {
			level = 5
			state_trigger = {
				state_region = s:STATE_PASTAZA
			}
		}
	}

	ai_weight = {
		value = 3 # Higher base value for flavored companies
	}
}

##############################DLC-COTS##############################

# Compañía Estañífera de Llallagua
TRY_REPLACE:company_estanifera_llallagua = {
	icon = "gfx/interface/icons/company_icons/historical_company_icons/bolivia_compania_estanifera_de_llallagua.dds"
	background = "gfx/interface/icons/company_icons/company_backgrounds/comp_illu_mining.dds"

	flavored_company = yes

	preferred_headquarters = { STATE_POTOSI }

	building_types = {
		building_lead_mine
	}

	extension_building_types = {
		building_iron_mine
		building_sulfur_mine
	}

	potential = {
		has_dlc_feature = rp1_content
		has_interest_marker_in_region = sr:region_andes
	}

	attainable = {
		hidden_trigger = { # Hide attainable if it's always fulfilled by possible
			any_scope_state = {
				state_region = s:STATE_POTOSI
			}
		}
	}

	possible = {
		any_scope_state = {
			state_region = s:STATE_POTOSI
			is_incorporated = yes
			any_scope_building = {
				is_building_type = building_lead_mine
				level >= 5
			}
		}
	}

	prosperity_modifier = {
		building_lead_mine_throughput_add = 0.1
		interest_group_ig_industrialists_pol_str_mult = 0.15
	}

	ai_will_do = {
		any_scope_state = {
			state_region = s:STATE_POTOSI
			is_incorporated = yes
		}
	}

	ai_construction_targets = {
		building_lead_mine = {
			level = 5
			state_trigger = {
				state_region = s:STATE_POTOSI
			}
		}
	}

	ai_weight = {
		value = 3 # Higher base value for flavored companies
	}
}

# Empresas Eléctricas Asociadas
TRY_REPLACE:company_eea = {
	icon = "gfx/interface/icons/company_icons/historical_company_icons/peru_empresas_electricas_asociadas.dds"
	background = "gfx/interface/icons/company_icons/company_backgrounds/comp_illu_manufacturing_light.dds"

	flavored_company = yes

	preferred_headquarters = { STATE_LIMA }

	building_types = {
		building_power_plant
	}

	extension_building_types = {
		building_coal_mine
	}

	potential = {
		has_dlc_feature = rp1_content
		has_interest_marker_in_region = sr:region_andes
	}

	attainable = {
		hidden_trigger = { # Hide attainable if it's always fulfilled by possible
			any_scope_state = {
				state_region = s:STATE_LIMA
			}
		}
	}

	possible = {
		has_technology_researched = electrical_generation
		any_scope_state = {
			state_region = s:STATE_LIMA
			is_incorporated = yes
			any_scope_building = {
				is_building_type = building_power_plant
				level >= 5
			}
		}
	}

	prosperity_modifier = {
		state_infrastructure_from_population_mult = 0.05
		state_construction_mult = 0.05
	}

	ai_will_do = {
		has_technology_researched = electrical_generation
		any_scope_state = {
			state_region = s:STATE_LIMA
			is_incorporated = yes
		}
	}

	ai_construction_targets = {
		building_power_plant = {
			level = 5
			state_trigger = {
				state_region = s:STATE_LIMA
			}
		}
	}

	ai_weight = {
		value = 3 # Higher base value for flavored companies
	}
}

# Compañía de Salitres y Ferrocarril de Antofagasta
TRY_REPLACE:company_csfa = {
	icon = "gfx/interface/icons/company_icons/historical_company_icons/bolivia_csfa.dds"
	background = "gfx/interface/icons/company_icons/company_backgrounds/comp_illu_railways.dds"

	flavored_company = yes

	preferred_headquarters = { STATE_ANTOFAGASTA }

	building_types = {
		building_sulfur_mine
		building_railway
	}

	extension_building_types = {
		building_iron_mine
	}

	potential = {
		has_interest_marker_in_region = sr:region_andes
	}

	attainable = {
		hidden_trigger = { # Hide attainable if it's always fulfilled by possible
			any_scope_state = {
				state_region = s:STATE_ANTOFAGASTA
			}
		}
	}

	possible = {
		has_technology_researched = railways
		any_scope_state = {
			state_region = s:STATE_ANTOFAGASTA
			is_incorporated = yes
			any_scope_building = {
				is_building_type = building_sulfur_mine
				level >= 5
			}
		}
	}

	prosperity_modifier = {
		state_infrastructure_mult = 0.05
		interest_group_ig_industrialists_approval_add = 3
	}

	ai_will_do = {
		has_technology_researched = railways
		any_scope_state = {
			state_region = s:STATE_ANTOFAGASTA
			is_incorporated = yes
		}
	}

	ai_construction_targets = {
		building_sulfur_mine = {
			level = 5
			state_trigger = {
				state_region = s:STATE_ANTOFAGASTA
			}
		}
	}

	ai_weight = {
		value = 3 # Higher base value for flavored companies
	}
}

# Fábrica de Armas de la Nación
TRY_REPLACE:company_famae = {
	icon = "gfx/interface/icons/company_icons/historical_company_icons/chile_fabrica_de_armas_de_la_nacion.dds"
	background = "gfx/interface/icons/company_icons/company_backgrounds/comp_illu_manufacturing_heavy.dds"

	flavored_company = yes

	preferred_headquarters = { STATE_SANTIAGO }

	building_types = {
		building_arms_industry
		building_artillery_foundry
		building_munition_plant
	}

	extension_building_types = {
		building_explosives_factory
	}

	possible_prestige_goods = {
		prestige_good_generic_small_arms
	}

	prestige_goods_trigger = {
		custom_tooltip = {
			text = je_prestige_goods_small_arms_complete_tt
			has_variable = prestige_good_generic_small_arms_var
		}
	}

	potential = {
		has_interest_marker_in_region = sr:region_la_plata
	}

	attainable = {
		hidden_trigger = { # Hide attainable if it's always fulfilled by possible
			any_scope_state = {
				state_region = s:STATE_SANTIAGO
			}
		}
	}

	possible = {
		has_technology_researched = gunsmithing
		any_scope_state = {
			state_region = s:STATE_SANTIAGO
			is_incorporated = yes
			any_scope_building = {
				is_building_type = building_arms_industry
				level >= 5
			}
		}
	}

	prosperity_modifier = {
		unit_offense_mult = 0.1
		building_steel_mill_throughput_add = 0.05
	}

	ai_will_do = {
		has_technology_researched = gunsmithing
		any_scope_state = {
			state_region = s:STATE_SANTIAGO
			is_incorporated = yes
		}
	}

	ai_construction_targets = {
		building_arms_industry = {
			level = 5
			state_trigger = {
				state_region = s:STATE_SANTIAGO
			}
		}
	}

	ai_weight = {
		value = 3 # Higher base value for flavored companies
	}
}

##############################MODDED##############################

# Grieve's Workshop
company_Grieve = {
	icon = "gfx/interface/icons/company_icons/basic_motors.dds"
	background = "gfx/interface/icons/company_icons/company_backgrounds/comp_illu_manufacturing_light.dds"
	
	flavored_company = yes
	preferred_headquarters = { STATE_LIMA }

	possible_prestige_goods = {
		#prestige_good_saint_etienne_rifles
	}
	
	building_types = { #28
		building_automotive_industry
	}
	
	extension_building_types = {
		building_motor_industry
		building_tooling_workshop
	}
	
	potential = {
		has_interest_marker_in_region = sr:region_andes
	}
	
	attainable = {
		hidden_trigger = { # Hide attainable if it's always fulfilled by possible
			any_scope_state = {
				state_region = s:STATE_LIMA
			}
		}
	}		
	
	possible = {
		any_scope_state = {
			state_region = s:STATE_LIMA
			is_incorporated = yes
			any_scope_building = {
				is_building_type = building_automotive_industry
				level >= 3
			}
		}
		has_technology_researched = combustion_engine
	}
	
	prosperity_modifier = {
		state_migration_pull_mult = 0.1 #14
		country_prestige_mult = 0.04 #4
		state_trade_advantage_mult = 0.06 #4
		goods_output_automobiles_mult = 0.08 #6
	}

	ai_will_do = {
		has_technology_researched = combustion_engine
		any_scope_state = {
			state_region = s:STATE_LIMA
			is_incorporated = yes
		}
	}

	ai_construction_targets = {
		building_automotive_industry = {
			level = 5
			state_trigger = {
				state_region = s:STATE_LIMA
			}
		}
	}
	ai_weight = {
		value = 3 # Higher base value for flavored companies
	}
}

# Caracoles
company_Caracoles = {
	icon = "gfx/interface/icons/company_icons/basic_gold_mining.dds"
	background = "gfx/interface/icons/company_icons/company_backgrounds/comp_illu_mining.dds"
	
	flavored_company = yes
	preferred_headquarters = { STATE_ANTOFAGASTA }

	possible_prestige_goods = {
		#prestige_good_saint_etienne_rifles
	}

	
	
	building_types = { #22
		building_gold_mine
	}
	
	extension_building_types = {
		building_coal_mine
		building_lead_mine
	}
	
	potential = {
		has_interest_marker_in_region = sr:region_andes
	}
	
	attainable = {
		hidden_trigger = { # Hide attainable if it's always fulfilled by possible
			any_scope_state = {
				state_region = s:STATE_ANTOFAGASTA
			}
		}
	}		
	
	possible = {
		any_scope_state = {
			state_region = s:STATE_ANTOFAGASTA
			is_incorporated = yes
			any_scope_building = {
				is_building_type = building_gold_mine
				level >= 3
			}
		}
	}
	
	prosperity_modifier = {
		state_migration_pull_mult = 0.06 #8
		country_minting_mult = 0.05 #14
	}
	

	ai_will_do = {
		any_scope_state = {
			state_region = s:STATE_ANTOFAGASTA
			is_incorporated = yes
		}
	}

	ai_construction_targets = {
		building_gold_mine = {
			level = 5
			state_trigger = {
				state_region = s:STATE_ANTOFAGASTA
			}
		}
	}
	ai_weight = {
		value = 3 # Higher base value for flavored companies
	}
}

# Ochagavia Wines
company_VinaO = {
	icon = "gfx/interface/icons/company_icons/historical_company_icons/ochagavia.png"
	background = "gfx/interface/icons/company_icons/company_backgrounds/comp_illu_farm_wheat.dds"
	
	flavored_company = yes
	preferred_headquarters = { STATE_SANTIAGO }

	possible_prestige_goods = {
		#prestige_good_saint_etienne_rifles
	}

	
	building_types = { #26
		building_vineyard
	}
	
	extension_building_types = {
		building_livestock_ranch
	}
	
	potential = {
		has_interest_marker_in_region = sr:region_andes
	}
	
	attainable = {
		hidden_trigger = { # Hide attainable if it's always fulfilled by possible
			any_scope_state = {
				state_region = s:STATE_SANTIAGO
			}
		}
	}		
	
	possible = {
		any_scope_state = {
			state_region = s:STATE_SANTIAGO
			is_incorporated = yes
			any_scope_building = {
				is_building_type = building_vineyard
				level >= 3
			}
		}
	}
	
	prosperity_modifier = {
		country_prestige_mult = 0.12 #12
		state_migration_pull_mult = 0.1 #14
	}
	

	ai_will_do = {
		any_scope_state = {
			state_region = s:STATE_SANTIAGO
			is_incorporated = yes
		}
	}

	ai_construction_targets = {
		building_vineyard = {
			level = 5
			state_trigger = {
				state_region = s:STATE_SANTIAGO
			}
		}
	}
	ai_weight = {
		value = 3 # Higher base value for flavored companies
	}
}

# La Ibérica
company_Iberica = {
	icon = "gfx/interface/icons/company_icons/historical_company_icons/iberica2.png"
	background = "gfx/interface/icons/company_icons/company_backgrounds/comp_illu_manufacturing_light.dds"
	
	flavored_company = yes
	preferred_headquarters = { STATE_AREQUIPA }

	possible_prestige_goods = {
		prestige_good_generic_groceries
	}

	
	
	building_types = { #29
		building_food_industry
	}
	
	extension_building_types = {
		building_maize_farm
		building_livestock_ranch
	}
	
	potential = {
		has_interest_marker_in_region = sr:region_andes
	}
	
	attainable = {
		hidden_trigger = { # Hide attainable if it's always fulfilled by possible
			any_scope_state = {
				state_region = s:STATE_AREQUIPA
			}
		}
	}		
	
	possible = {
		any_scope_state = {
			state_region = s:STATE_AREQUIPA
			is_incorporated = yes
			any_scope_building = {
				is_building_type = building_food_industry
				level >= 3
			}
		}
		has_technology_researched = vacuum_canning
	}
	
	prosperity_modifier = {
		state_birth_rate_mult = 0.05 #20
		state_migration_pull_mult = 0.06 #8
	}

	ai_will_do = {
		has_technology_researched = vacuum_canning
		any_scope_state = {
			state_region = s:STATE_AREQUIPA
			is_incorporated = yes
		}
	}

	ai_construction_targets = {
		building_food_industry = {
			level = 5
			state_trigger = {
				state_region = s:STATE_AREQUIPA
			}
		}
	}
	ai_weight = {
		value = 3 # Higher base value for flavored companies
	}
}

# Patiño_Mines
company_Patino_mines = {
	icon = "gfx/interface/icons/company_icons/historical_company_icons/patinomines.png" 
	background = "gfx/interface/icons/company_icons/company_backgrounds/comp_illu_mining.dds"
	
	flavored_company = yes
	preferred_headquarters = { STATE_LA_PAZ }

	possible_prestige_goods = {
		prestige_good_generic_tin
	}
	
	
	building_types = { #22
		building_lead_mine
		building_steel_mill
	}
	
	extension_building_types = {
		building_iron_mine
		building_coal_mine
		building_railway
	}
	
	potential = {
		has_interest_marker_in_region = sr:region_andes
	}
	
	attainable = {
		hidden_trigger = { # Hide attainable if it's always fulfilled by possible
			OR = {
				any_scope_state = {
					state_region = s:STATE_POTOSI
					is_incorporated = yes
					any_scope_building = {
						is_building_type = building_lead_mine
						level >= 3
					}
				}
				AND = {
					any_scope_state = {
						is_incorporated = yes
						any_scope_building = {
							is_building_type = building_steel_mill
							level >= 3
						}
					}
					AND = { 
						exists = c:BOL
						c:BOL = { relations:root >= relations_threshold:amicable }
					}
				}	
			}	
		}
	}	

	possible = {
		OR = {
			any_scope_state = {
				state_region = s:STATE_POTOSI
				is_incorporated = yes
				any_scope_building = {
					is_building_type = building_lead_mine
					level >= 3
				}
			}
			AND = {
				any_scope_state = {
					is_incorporated = yes
					any_scope_building = {
						is_building_type = building_steel_mill
						level >= 3
					}
				}
				AND = { 
					exists = c:BOL
					c:BOL = { relations:root >= relations_threshold:amicable }
				}
			}
		}
		has_technology_researched = pneumatic_tools
	}
	
	prosperity_modifier = {
		building_food_industry_throughput_add = 0.1 #10
		building_group_bg_heavy_industry_throughput_add = 0.02 #12
	}
	

	ai_will_do = {
		has_technology_researched = pneumatic_tools
		any_scope_state = {
			state_region = s:STATE_POTOSI
			is_incorporated = yes
		}
	}

	ai_construction_targets = {
		building_lead_mine = {
			level = 5
			state_trigger = {
				state_region = s:STATE_POTOSI
			}
		}
	}
	ai_weight = {
		value = 3 # Higher base value for flavored companies
	}
}

# Banco Italiano (Peru) later Banco de Crédito del Perú
company_bank_peru = {
	icon = "gfx/interface/icons/company_icons/historical_company_icons/bank_peru.png" 
	background = "gfx/interface/icons/company_icons/company_backgrounds/comp_illu_manufacturing_light.dds"
	
	flavored_company = yes
	preferred_headquarters = { STATE_LIMA }
	
	possible_prestige_goods = {
		#prestige_good_generic_currency_paper
	}
	
	building_types = {  
		building_paper_mill
		building_tobacco_plantation
		building_railway
	}
	
	extension_building_types = {	
		building_sugar_plantation
		building_textile_mill
		building_steel_mill
		building_iron_mine
	}
	
	potential = {
		has_game_rule = banks_enabled
		has_interest_marker_in_region = sr:region_andes
	}
	
	attainable = {
		hidden_trigger = { # Hide attainable if it's always fulfilled by possible
			any_scope_state = {
				state_region = s:STATE_LIMA
			}
		}
	}	

	possible = {
		any_scope_state = {
			state_region = s:STATE_LIMA
			is_incorporated = yes
			any_scope_building = {
				is_building_type = building_financial_district
				level >= 15
			}
		}
		has_technology_researched = investment_banks
		unique_companies_has_bank = no
	}
	
	prosperity_modifier = {
		state_assimilation_mult = 0.1
		state_migration_pull_mult = 0.1
		
		country_minting_mult = 0.025
		country_loan_interest_rate_mult = -0.025
        country_private_construction_allocation_mult = 0.1		
		
		state_farmers_investment_pool_contribution_add = 0.015
		state_shopkeepers_investment_pool_contribution_add = 0.015
		state_clergymen_investment_pool_contribution_add = 0.04
		state_aristocrats_investment_pool_contribution_add = 0.04
		state_capitalists_investment_pool_contribution_add = 0.065
		
		building_nationalization_investment_return_add = 0.05
		country_government_dividends_reinvestment_add = 0.05
		country_government_dividends_efficiency_add = 0.05
		
		country_max_companies_add = 1
	}
	
	ai_will_do = {
	    unique_companies_has_bank = no
		has_technology_researched = investment_banks
		any_scope_state = {
			state_region = s:STATE_LIMA
			is_incorporated = yes
		}
	}

	ai_construction_targets = {
		building_paper_mill = {
			level = 5
			state_trigger = {
				state_region = s:STATE_LIMA
			}
		}
	}
	ai_weight = {
		value = 5 # Higher base value for flavored companies
	}
}

# La Brea y Pariñas / International Petroleum Company, Ltd. (combined)
company_oil_la_brea = {
	icon = "gfx/interface/icons/company_icons/basic_oil.dds"
	background = "gfx/interface/icons/company_icons/company_backgrounds/comp_illu_oil_drills.dds"
	
	flavored_company = yes
	preferred_headquarters = { STATE_CAJAMARCA STATE_PASTAZA }
	
	possible_prestige_goods = {
		#prestige_good_saint_etienne_rifles
	}

	building_types = {  #22
		building_oil_rig
	}
	
	extension_building_types = {
		building_coal_mine
		building_railway
	}

	potential = {
		has_interest_marker_in_region = sr:region_andes
	}
	
	attainable = {
		hidden_trigger = { # Hide attainable if it's always fulfilled by possible
			any_scope_state = {
				OR = {
					state_region = s:STATE_CAJAMARCA
					state_region = s:STATE_PASTAZA
				}
			}
		}
	}	
	
	possible = {
		any_scope_state = {
			OR = {
				state_region = s:STATE_CAJAMARCA
				state_region = s:STATE_PASTAZA
			}
			is_incorporated = yes
			any_scope_building = {
				is_building_type = building_oil_rig
				level >= 5
			}
		}
		OR = {
			AND = { 
				exists = c:USA
				c:USA = { relations:root >= relations_threshold:amicable }
			}
			AND = { 
				exists = c:GBR
				c:GBR = { relations:root >= relations_threshold:amicable }
			}
		}
	}
	
	prosperity_modifier = {
		building_group_bg_oil_extraction_laborers_mortality_mult = 0.1 #+5
		building_group_bg_oil_extraction_throughput_add = 0.1 #20
		country_private_construction_allocation_mult = 0.08 # 8
	}
	

	ai_will_do = {
		OR = {
			any_scope_state = {
				state_region = s:STATE_CAJAMARCA
				is_incorporated = yes
			}
			any_scope_state = {
				state_region = s:STATE_PASTAZA
				is_incorporated = yes
			}
		}
	}

	ai_construction_targets = {
		building_oil_rig = {
			level = 5
			state_trigger = {
				state_region = s:STATE_PASTAZA
			}
		}
		building_oil_rig = {
			level = 5
			state_trigger = {
				state_region = s:STATE_CAJAMARCA
			}
		}
	}
	ai_weight = {
		value = 3 # Higher base value for flavored companies
	}
}