###########################
# FP3 CULTURAL TRADITIONS 
###########################

#######################
# Central Asian Specific
#######################

tradition_fp3_frontier_warriors = {
	category = regional

	layers = {
		0 = martial
		1 = mena
		4 = dismounted_warrior.dds
	}
	
	is_shown = {
		# DLC check.
		has_fp3_dlc_trigger = yes
		
		# Any culture present in the given area can pick this
		any_culture_county = {
			any_county_province = {
				OR = {
					geographical_region = world_transoxiana
					geographical_region = world_khorasan
					geographical_region = world_steppe_tarim
				}
			}
		}
	}

	can_pick = {
		culture_not_pacifistic_trigger = yes
		# Must have a significant cultural presence in the general Turanian area, i.e. the "frontier"
		custom_tooltip = {
			text = culture_on_eastern_frontier_desc
			any_culture_county = {
				percent >= 0.2
				any_county_province = {
					OR = {
						geographical_region = world_transoxiana
						geographical_region = world_khorasan
						geographical_region = world_steppe_tarim
					}
				}
			}
		}	
	}
	
	parameters = {
		unlock_maa_tarkhan = yes
		faith_warrior_traits_more_valued = yes
	}
	province_modifier = {
		hostile_raid_time = 0.5
	}
	character_modifier = {
		mercenary_hire_cost_mult = -0.10
		movement_speed = 0.05
	}
	
	cost = {
		prestige = {
			# Base cost.
			add = {
				value = tradition_base_cost
				desc = BASE
				format = "BASE_VALUE_FORMAT"
			}
			# Ethos requirement.
			if = {
				limit = {
					NOR = {
						culture_pillar:ethos_bellicose = { is_in_list = traits }
						culture_pillar:ethos_stoic = { is_in_list = traits }
					}
				}
				add = {
					value = tradition_incompatible_ethos_penalty
					desc = not_bellicose_or_stoic_desc
				}
			}
			# Gotta be a steppe-heavy culture not to get a surcharge.
			if = {
				limit = {
					NOT = {
						any_culture_county = {
							percent >= 0.3
							county_has_province_with_terrain = {
								terrain = steppe 
								terrain = desert
							}
						}
					}
				}
				add = {
					value = tradition_unfulfilled_criteria_penalty
					desc = steppe_or_desert_percentage_desc
				}
			}
			#Turko-Mongol-Iranians get it cheaper!
			if = {
				limit = {
					NOR = {
						has_cultural_pillar = heritage_iranian
						has_cultural_pillar = heritage_turkic
						has_cultural_pillar = heritage_mongolic
						has_cultural_pillar = heritage_tocharian
					}
				}
				add = {
					value = tradition_unfulfilled_criteria_penalty
					desc = not_of_central_asian_heritage_desc
				}
			}

			if = {
				limit = {
					culture_tradition_reduction_trigger = { TRADITION = tradition_fp3_frontier_warriors }
				}
				multiply = {
					value = 0.5
					desc = inspired_by_culture_desc
				}
			}
			
			multiply = tradition_replacement_cost_if_relevant
		}
	}
	
	ai_will_do = { 
		value = 100
		if = {
			limit = {
				NOT = {
					scope:character = {
						any_sub_realm_county = {
							percent >= 0.3
							county_has_province_with_terrain = {
								terrain = steppe 
							}
						}
					}
				}
			}
			multiply = 0
		}
	}
}

#######################
# Persian Specific
#######################

tradition_fp3_irrigation_experts = {
	category = realm

	layers = {
		0 = steward
		1 = mena
		4 = water_technology.dds
	}

	is_shown = {
		# DLC check.
		has_fp3_dlc_trigger = yes
		has_cultural_pillar = heritage_iranian
		NOT = { has_cultural_tradition = tradition_dryland_dwellers }
	}
	
	can_pick = {
		custom_description = {
			text = culture_in_dryland_desc
			any_culture_county = {
				county_has_province_with_terrain = {
					terrain = drylands
					terrain = desert
					terrain = desert_mountains
				}
			}
		}
		# Shouldn't be combined with the following traditions:
		custom_tooltip = {
			text = cannot_have_tradition_dryland_dwellers
			NOT = { culture_tradition:tradition_dryland_dwellers = { is_in_list = traits } } #this is another approach to drylands dwelling
		}
	}
	
	parameters = {
		innovative_traits_more_valued = yes
		unlocks_qanat_building = yes
		plantations_building_bonuses = yes
		drylands_hunt_success_chance = yes
	}
	character_modifier = {
		negate_health_penalty_add = 0.1
		desert_travel_danger = desert_medium_danger_reduction
		drylands_travel_danger = drylands_medium_danger_reduction
		desert_mountains_travel_danger = desert_mountains_medium_danger_reduction
	}
	county_modifier = {
		desert_development_growth_factor = 0.35
		drylands_development_growth_factor = 0.15
	}
	province_modifier = {
		desert_construction_gold_cost = -0.1
		drylands_construction_gold_cost = -0.1
		desert_holding_construction_gold_cost = -0.1
		drylands_holding_construction_gold_cost = -0.1
	}
	
	cost = {
		prestige = {
			add = {
				value = tradition_base_cost
				desc = BASE
				format = "BASE_VALUE_FORMAT"
			}
			if = {
				limit = {
					NOR = {
						culture_pillar:ethos_courtly = { is_in_list = traits }
						culture_pillar:ethos_communal = { is_in_list = traits }
						culture_pillar:ethos_egalitarian = { is_in_list = traits }
					}
				}
				add = {
					value = tradition_incompatible_ethos_penalty
					desc = not_communal_egalitarian_or_courtly_desc
				}
			}
			if = {
				limit = {
					NOT = {
						any_culture_county = {
							percent >= 0.3
							county_has_province_with_terrain = {
								terrain = drylands
								terrain = desert
							}
						}
					}
				}
				add = {
					value = tradition_unfulfilled_criteria_penalty
					desc = dry_percentage_desc
				}
			}

			if = {
				limit = {
					culture_tradition_reduction_trigger = { TRADITION = tradition_fp3_irrigation_experts }
				}
				multiply = {
					value = 0.5
					desc = inspired_by_culture_desc
				}
			}
			
			multiply = tradition_replacement_cost_if_relevant
		}
	}
	
	ai_will_do = {
		value = 400
		if = {
			limit = {
				NOT = { #if the realm isn't very dry, the AI won't pick this
					scope:character = {
						any_sub_realm_county = {
							percent >= 0.4
							culture = scope:character.culture
							county_has_province_with_terrain = {
								terrain = drylands
								terrain = desert
							}
						}
					}
				}
			}
			multiply = 0
		}
		else_if = {
			limit = {
				any_culture_county = {
					percent >= 0.6
					county_has_province_with_terrain = {
						terrain = drylands
						terrain = desert
					}
				}
			}
			multiply = 4
		}
	}
}

tradition_fp3_beacon_of_learning = { # Offshoot of tradition_philosopher_culture
	category = societal

	layers = {
		0 = learning
		1 = mena
		4 = beacon_of_learning.dds
	}
	
	is_shown = {
		has_fp3_dlc_trigger = yes
		has_cultural_pillar = heritage_iranian
		NOT = { has_cultural_tradition = tradition_philosopher_culture } # Replaces Philosopher Culture
	}

	can_pick = {
		custom_description = {
			text = culture_not_bellicose
			NOT = {
				culture_pillar:ethos_bellicose = { is_in_list = traits }
			}
		}
		NOT = { has_cultural_tradition = tradition_warrior_culture }
		NOT = { has_cultural_tradition = tradition_philosopher_culture }
	}
	can_pick_for_hybridization = {
		custom_tooltip = {
			text = no_warrior_culture
			NOT = { # Only blocks polygamous to avoid duplicate warnings, but is blocked by concubines
				culture_tradition:tradition_warrior_culture = { is_in_list = traits }
			}
		}
		custom_tooltip = {
			text = no_philosopher_culture
			NOT = { # Only blocks polygamous to avoid duplicate warnings, but is blocked by concubines
				culture_tradition:tradition_philosopher_culture = { is_in_list = traits }
			}
		}
	}
	
	parameters = {
		pensive_trait_more_common = yes
		rowdy_trait_less_common = yes
		innovation_from_learning_traits = yes
		can_appoint_court_scholar = yes
		guardian_education_better_outcomes = yes
	}

	character_modifier = {
		monthly_learning_lifestyle_xp_gain_mult = 0.2
		learning_per_piety_level = 1
	}
	
	cost = {
		prestige = {
			add = {
				value = tradition_base_cost
				desc = BASE
				format = "BASE_VALUE_FORMAT"
			}
			if = {
				limit = {
					NOR = {
						culture_pillar:ethos_courtly = { is_in_list = traits }
						culture_pillar:ethos_communal = { is_in_list = traits }
						culture_pillar:ethos_spiritual = { is_in_list = traits }
					}
				}
				add = {
					value = tradition_incompatible_ethos_penalty
					desc = not_courtly_communal_or_spiritual_desc
				}
			}
			if = {
				limit = {
					trigger_if = {
						limit = {
							scope:character = {
								is_ai = no
							}
						}
						NOT = {
							any_ruler = {
								count >= 5
								culture = prev
								primary_title.tier >= tier_county
								has_trait = scholar
							}
						}
					}
					trigger_else = {
						always = no
					}
				}
				add = {
					value = tradition_unfulfilled_criteria_penalty
					desc = rulers_with_scholar_desc
				}
			}

			if = {
				limit = {
					culture_tradition_reduction_trigger = { TRADITION = tradition_fp3_beacon_of_learning }
				}
				multiply = {
					value = 0.5
					desc = inspired_by_culture_desc
				}
			}
			
			multiply = tradition_replacement_cost_if_relevant
		}
	}
	
	ai_will_do = {
		value = 200
		if = {
			limit = {
				NOR = {
					culture_pillar:ethos_courtly = { is_in_list = traits }
					culture_pillar:ethos_communal = { is_in_list = traits }
					culture_pillar:ethos_spiritual = { is_in_list = traits }
				}
			}
			multiply = 0
		}
	}
}

# Replaces Refined Poetry
tradition_fp3_enlightened_magnates = {
	category = societal

	layers = {
		0 = diplo
		1 = mena
		4 = jirga.dds
	}

	is_shown = {
		has_fp3_dlc_trigger = yes
		has_cultural_pillar = heritage_iranian
		NOT = { has_cultural_parameter = poet_trait_gives_bonuses }
	}

	parameters = {
		poet_trait_gives_bonuses = yes
		poet_trait_more_common = yes
		characters_are_better_court_poets = yes
		characters_are_better_tax_collector = yes
		unlock_tax_obligation_deqhan = yes
	}

	character_modifier = {
		clan_tax_slot_add  = 1
	}

	cost = {
		prestige = {
			add = {
				value = tradition_base_cost
				desc = BASE
				format = "BASE_VALUE_FORMAT"
			}
			if = {
				limit = {
					NOR = {
						culture_pillar:ethos_courtly = { is_in_list = traits }
						culture_pillar:ethos_communal = { is_in_list = traits }
						culture_pillar:ethos_spiritual = { is_in_list = traits }
					}
				}
				add = {
					value = tradition_incompatible_ethos_penalty
					desc = not_courtly_communal_or_spiritual_desc
				}
			}
			if = {
				limit = {
					trigger_if = {
						limit = {
							scope:character = {
								is_ai = no
							}
						}
						NOT = {
							any_ruler = {
								count >= 3
								culture = prev
								primary_title.tier >= tier_county
								has_trait = lifestyle_poet
							}
						}
					}
					trigger_else = {
						always = no
					}
				}
				add = {
					value = tradition_unfulfilled_criteria_penalty
					desc = rulers_with_poet_desc
				}
			}

			if = {
				limit = {
					scope:character = {
						has_variable = tradition_poetry_travel_discount
					}

				}

				add = {
					value = tradition_travel_discount
					desc = tradition_travel_discount_desc
				}
			}

			if = {
				limit = {
					culture_tradition_reduction_trigger = { TRADITION = tradition_fp3_enlightened_magnates }
				}
				multiply = {
					value = 0.5
					desc = inspired_by_culture_desc
				}
			}

			multiply = tradition_replacement_cost_if_relevant
		}
	}

	ai_will_do = {
		value = 125
		if = {
			limit = { # AI should avoid stacking traditions for courtly court positions
				culture_tradition:tradition_music_theory = { is_in_list = traits }
			}
			multiply = 0.25
		}
	}
}

#######################
# Afghanistan/Baluchistan Specific
#######################

tradition_fp3_jirga = {
	category = regional

	layers = {
		0 = learning
		1 = indian
		4 = jirga.dds
	}
	
	is_shown = {
		# DLC check.
		has_fp3_dlc_trigger = yes
		OR = {
			has_cultural_pillar = heritage_iranian
			has_cultural_pillar = heritage_indo_aryan
		}
	}
	
	can_pick = {
		scope:character = {
			government_has_flag = government_is_tribal #This tradition is really a holdover from tribal culture, and though the Afghanis might have it despite having changed government forms, others cannot pick it now.
		}
	}
	
	parameters = {
		tribal_elective_enabled = yes
		just_trait_gives_bonuses = yes
		pardoning_gives_prestige = yes
	}
	character_modifier = {
		owned_personal_scheme_success_chance_add = 10
	}
	
	cost = {
		prestige = {
			add = {
				value = tradition_base_cost
				desc = BASE
				format = "BASE_VALUE_FORMAT"
			}
			if = {
				limit = {
					NOR = {
						culture_pillar:ethos_communal = { is_in_list = traits }
						culture_pillar:ethos_stoic = { is_in_list = traits }
					}
				}
				add = {
					value = tradition_incompatible_ethos_penalty
					desc = not_stoic_or_communal_desc
				}
			}
			if = {
				limit = {
					NOT = {
						scope:character = {
							any_sub_realm_county = {
								county_opinion < 0
							}
						}
					}
				}
				add = {
					value = tradition_unfulfilled_criteria_penalty
					desc = counties_with_low_county_opinion_desc
				}
			}

			if = {
				limit = {
					culture_tradition_reduction_trigger = { TRADITION = tradition_fp3_jirga }
				}
				multiply = {
					value = 0.5
					desc = inspired_by_culture_desc
				}
			}
			
			multiply = tradition_replacement_cost_if_relevant
		}
	}
	
	ai_will_do = {
		value = 100
		if = {
			limit = {
				OR = {
					culture_tradition:tradition_things = { is_in_list = traits }
					culture_tradition:tradition_the_witenagemot = { is_in_list = traits }
				}
			}
			multiply = 0
		}
	}
}

tradition_fp3_pragmatic_creed = {
	category = regional

	layers = {
		0 = diplo
		1 = mena
		4 = pragmatic_creed.dds
	}
	
	is_shown = {
		# DLC check.
		has_fp3_dlc_trigger = yes
		has_cultural_pillar = heritage_iranian
	}
	
	can_pick = {
		culture_not_pacifistic_trigger = yes
		custom_description = {
			text = culture_in_mountains_desc
			any_culture_county = {
				county_has_province_with_terrain = {
					terrain = mountains
					terrain = desert_mountains
				}
			}
		}
	}
	
	parameters = {
		unlock_maa_zupin_warrior = yes
		diligent_trait_more_common = yes
		pragmatic_traits_county_opinion_modifiers = yes
		commanders_likelier_to_gain_commander_traits = yes
	}
	character_modifier = {
		skirmishers_toughness_mult = 0.10
		skirmishers_maintenance_mult = -0.15
  		heavy_cavalry_maintenance_mult = 0.15
  		light_cavalry_maintenance_mult = 0.15
	}
	
	cost = {
		prestige = {
			add = {
				value = tradition_base_cost
				desc = BASE
				format = "BASE_VALUE_FORMAT"
			}
			if = {
				limit = {
					culture_pillar:ethos_courtly = { is_in_list = traits }
					culture_pillar:ethos_bureaucratic = { is_in_list = traits }
					culture_pillar:ethos_spiritual = { is_in_list = traits }
				}
				add = {
					value = tradition_incompatible_ethos_penalty
					desc = not_bureaucratic_courtly_or_spiritual_desc
				}
			}
			# Gotta be a mountain-heavy culture not to get a surcharge.
			if = {
				limit = {
					NOT = {
						any_culture_county = {
							percent >= 0.3
							county_has_province_with_terrain = {
								terrain = mountains
								terrain = desert_mountains
							}
						}
					}
				}
				add = {
					value = tradition_unfulfilled_criteria_penalty
					desc = mountain_percentage_desc
				}
			}

			if = {
				limit = {
					culture_tradition_reduction_trigger = { TRADITION = tradition_fp3_pragmatic_creed }
				}
				multiply = {
					value = 0.5
					desc = inspired_by_culture_desc
				}
			}
			
			multiply = tradition_replacement_cost_if_relevant
		}
	}
	
	ai_will_do = {
		value = 100
		if = {
			limit = {
				OR = { # Don't pick this if the culture have Light Cavalry or Heavy Cavalry MaAs
					culture_has_heavy_cavalry_maa = yes
					culture_has_light_cavalry_maa = yes
				}
			}
			multiply = 0
		}
		if = {
			limit = {
				NOT = { # Less likely for cultures who doesn't descend from Daylamite
					any_parent_culture_or_above = {
						this = culture:daylamite
					}
				}
			}
			multiply = 0.75
		}
	}
}

#######################
# Kurdish Specific
#######################

tradition_fp3_fierce_independence = {
	category = regional

	layers = {
		0 = martial
		1 = mena
		4 = fierce_independence.dds
	}
	
	is_shown = {
		has_fp3_dlc_trigger = yes
		has_cultural_pillar = heritage_iranian
	}

	can_pick = {
		NOT = {
			has_cultural_tradition = tradition_staunch_traditionalists
		}
	}
	
	parameters = {
		unlock_maa_tawashi = yes
		harder_to_hybridize = yes
		harder_to_convert_county_culture = yes
	}

	character_modifier = {
		controlled_province_advantage = 5
		same_culture_opinion = 5
		opinion_of_liege = -10
	}
	
	cost = {
		prestige = {
			add = {
				value = tradition_base_cost
				desc = BASE
				format = "BASE_VALUE_FORMAT"
			}
			if = {
				limit = {
					NOR = {
						culture_pillar:ethos_bellicose = { is_in_list = traits }
						culture_pillar:ethos_communal = { is_in_list = traits }
						culture_pillar:ethos_stoic = { is_in_list = traits }
					}
				}
				add = {
					value = tradition_incompatible_ethos_penalty
					desc = not_bellicose_stoic_or_communal_desc
				}
			}
			if = {
				limit = {
					scope:character = {
						any_sub_realm_county = {
							culture != scope:character.culture
						}
					}
				}
				add = {
					value = tradition_unfulfilled_criteria_penalty
					desc = has_other_cultures_in_realm_desc
				}
			}

			if = {
				limit = {
					culture_tradition_reduction_trigger = { TRADITION = tradition_fp3_fierce_independence }
				}
				multiply = {
					value = 0.5
					desc = inspired_by_culture_desc
				}
			}
			
			multiply = tradition_replacement_cost_if_relevant
		}
	}
	
	ai_will_do = {
		value = 400
		if = {
			limit = {
				NOR = {
					culture_pillar:ethos_stoic = { is_in_list = traits }
					culture_pillar:ethos_communal = { is_in_list = traits }
				}
			}
			multiply = 0.5
		}
	}
}
