﻿iberian_struggle = {
	# has_fp2_dlc_trigger = yes  #TODO_CD_AN Request support for dlc locking on struggles

	##################################################
	# Setup
	##################################################
	cultures = {
		# Northern
		basque
		castilian
		catalan
		portuguese
		galician
		asturleonese
		aragonese
		#Modded for compatibility with More Bookmarks Plus by Leviathonlx and because it makes sense
		visigothic
		suebi
		# Southern
		andalusian
		# Outsider
		bedouin
		levantine
		maghrebi
		baranis
		# Minorities
		sephardi
		#Modded for compatibility with More Bookmarks Plus by Leviathonlx
		masmuda #For Almohads #Custom culture added by More Bookmarks Plus by Leviathonlx
	}
	faiths = {
		# Christian
		catholic mozarabic_church
		# Islamic
		ashari muwalladi
		#Modded for compatibility with More Bookmarks Plus by Leviathonlx and because it makes sense
		# Basque Pagan
		basque_pagan
		#Modded: Jewish faiths - Inspired by Jewish Iberian Struggle by Noot Noot
		rabbinism
		#Modded: Note conversos faith is a christianity_religion
		conversos
	}
	regions = {
		world_europe_west_iberia
	}

	# A culture or faith becomes involved if 80% of the total number of counties belonging to it are inside the struggle region.
	involvement_prerequisite_percentage = 0.8

	on_start = {
		# Starting Events
		trigger_event = { on_action = fp2_iberian_struggle_starting_events }
	}

	on_change_phase = {

		# Set up AI Intent
		trigger_event = fp2_struggle.0003
	}
	
	# Root = the current struggle
	# scope:character = the character which has joined the struggle
 	on_join = {
		if = {
			limit = {
				is_ai = no
			}

			trigger_event = fp2_struggle.0501
		}
		else = {
			# assign an intent to the freshly joined character
			trigger_event = fp2_struggle.004
		}
 	}
	
	##################################################
	# Phases
	##################################################
	start_phase = struggle_iberia_phase_opportunity	
	
	phase_list = {

		# Opportunity Phase represents complacency after a long period of coexistence during Conciliation; people are comfortable that things are good and so actors with ill-intent can get away with things once again.
		struggle_iberia_phase_opportunity = {
			##################################################
			# General Set-Up

			background = "gfx/interface/illustrations/struggle_backgrounds/struggle_opportunity_bg.dds"
			
			future_phases = {
				struggle_iberia_phase_hostility = {						
					catalysts = {
						catalyst_passing_of_time = minimal_struggle_catalyst_gain
						catalyst_gain_claim_on_title = minor_struggle_catalyst_gain
						catalyst_win_any_war_within_the_region = minor_struggle_catalyst_gain # Good
						catalyst_new_building_in_castle = minor_struggle_catalyst_gain # How to do AI?
						catalyst_becomes_rival_with_involved = major_struggle_catalyst_gain # Good
						catalyst_using_a_hook_on_very_important_character = medium_struggle_catalyst_gain # good
						catalyst_unnatural_death_important_character = medium_struggle_catalyst_gain
						catalyst_usurp_title = major_struggle_catalyst_gain # good
						catalyst_forced_conversion = medium_struggle_catalyst_gain
						catalyst_reveal_secret_important = major_struggle_catalyst_gain
						catalyst_broke_truce_against_important_character = massive_struggle_catalyst_gain # Cannot motivate the AI to do that without code support
					}
				}
				struggle_iberia_phase_conciliation = {
					catalysts = {
						catalyst_improve_development_vassal_diff_faith_culture = minimal_struggle_catalyst_gain # How to do AI?
						catalyst_gift_independent_ruler = minor_struggle_catalyst_gain # AI done
						catalyst_became_friend_lover_with_character = minor_struggle_catalyst_gain
						catalyst_learned_new_language_important = minor_struggle_catalyst_gain # AI done
						catalyst_new_building_in_city = minor_struggle_catalyst_gain # How to do AI?
						catalyst_sign_truce_outside_war = minor_struggle_catalyst_gain # will need update when addding truce through wards
						catalyst_formed_interreligious_alliance_with_important_character = minor_struggle_catalyst_gain
						catalyst_ransom_important = medium_struggle_catalyst_gain
						catalyst_grant_privilege_to_diff_faith_culture_vassal = medium_struggle_catalyst_gain
						catalyst_invite_diff_faith_culture_to_feast = medium_struggle_catalyst_gain
						catalyst_independence_from_non_dejure_vassal = major_struggle_catalyst_gain
						catalyst_grant_land_local_noble = major_struggle_catalyst_gain
						catalyst_became_best_friend_soulmate_with_very_important_character = major_struggle_catalyst_gain # AI done
						catalyst_convert_local_culture_faith = major_struggle_catalyst_gain
						catalyst_release_important = massive_struggle_catalyst_gain
					}
				}
			}

			war_effects = {
				###### Common

				# Nothing

				###### Involved
				involved_parameters = {
					claims_in_region_cost_prestige_not_gold_for_involved_parties = yes
					involved_or_interloper_wars_in_struggle_region_cheaper_prestige_costs = yes
					unlocks_border_raid_casus_belli = yes
					unlocks_contract_assistance_interaction = yes
					unlocks_bargain_fealty_interaction = yes
				}

				involved_character_modifier = {
					mercenary_hire_cost_mult = -0.3
					ai_war_chance = 0.25
					ai_war_cooldown = -0.25
				}

				###### Interlopers
				interloper_parameters = {
					involved_or_interloper_wars_in_struggle_region_cheaper_prestige_costs = yes
				}

				###### Uninvolved

				# Nothing
			}

			faith_effects = {
				###### Common
				common_parameters = {
					cheaper_to_convert_to_struggle_faith = yes
					county_faith_conversion_in_region_proceeds_faster = yes
					holy_wars_in_region_cannot_be_declared = yes
				}

				###### Involved
				involved_parameters = {
					interfaith_marriages_available_between_involved_characters = yes
				}

				###### Interlopers

				# Nothing

				###### Uninvolved

				# Nothing

			}

			culture_effects = {
				###### Common
				common_parameters = {
					cheaper_to_convert_to_struggle_culture = yes
				}

				###### Involved
				involved_parameters = {
					learning_languages_gives_prestige = yes
					granting_title_to_local_noble_gives_prestige = yes
					gain_acceptance_when_developing_other_culture_county = yes
				}

				###### Interlopers

				# Nothing

				###### Uninvolved

				# Nothing
			}

			other_effects = {
				###### Common

				# Nothing


				###### Involved
				involved_parameters = {
					unlocks_buy_claim_for_all = yes
					unlocks_demand_payments_for_all = yes
					unlocks_abduct_for_all = yes
					unlocks_fabricate_hooks_for_all = yes
					unlocks_claim_throne_for_all = yes
					unlocks_incite_revolts_interaction = yes
					struggle_unlocks_befriend_schemes_for_everyone = yes
					unlocks_epic_commission_for_independent_rulers = yes
					unlocks_truce_purchasing_interaction = yes
					unlocks_sell_minor_title_for_kings_and_higher = yes
				}

				###### Interlopers
				interloper_parameters = {
					unlocks_secure_iberian_foothold_decision = yes
				}

				interloper_character_modifier = {
					county_opinion_add = -5
					tax_mult = -0.1
				}

				###### Uninvolved
				uninvolved_parameters = {
					unlocks_secure_iberian_foothold_decision = yes
				}

				uninvolved_county_modifier = {
					county_opinion_add = -10
					tax_mult = -0.15
				}

			}

			#We are listing all available decision to give players insights on how they can end the Struggle
			ending_decisions = {
				struggle_iberia_ending_hostility_decision
				struggle_iberia_ending_compromise_decision
				struggle_iberia_ending_conciliation_decision
			 }
		}

		# The Hostility phase accounts for the more brutal & fundamentalist side of the struggle; intolerance and violence break out even in stable areas & resentments over slights real or imagined escalate dramatically.
		# Should we add a transition to Opportunity? A smaller deescalation than going to compromise
		struggle_iberia_phase_hostility = {
			##################################################
			# General Set-Up

			background = "gfx/interface/illustrations/struggle_backgrounds/struggle_hostility_bg.dds"

			future_phases = {
				struggle_iberia_phase_compromise = {
					catalysts = {
						catalyst_passing_of_time = minimal_struggle_catalyst_gain
						catalyst_improve_development_vassal_diff_faith_culture = minimal_struggle_catalyst_gain
						catalyst_gift_independent_ruler = minor_struggle_catalyst_gain
						catalyst_became_friend_lover_with_character = minor_struggle_catalyst_gain
						catalyst_learned_new_language_important = minor_struggle_catalyst_gain
						catalyst_new_building_in_city = minor_struggle_catalyst_gain
						catalyst_sign_truce_outside_war = minor_struggle_catalyst_gain
						catalyst_formed_interreligious_alliance_with_important_character = minor_struggle_catalyst_gain
						catalyst_ransom_important = medium_struggle_catalyst_gain
						catalyst_grant_privilege_to_diff_faith_culture_vassal = medium_struggle_catalyst_gain
						catalyst_invite_diff_faith_culture_to_feast = medium_struggle_catalyst_gain
						catalyst_independence_from_non_dejure_vassal = major_struggle_catalyst_gain
						catalyst_grant_land_local_noble = major_struggle_catalyst_gain
						catalyst_became_best_friend_soulmate_with_very_important_character = major_struggle_catalyst_gain
						catalyst_convert_local_culture_faith = major_struggle_catalyst_gain
						catalyst_release_important = massive_struggle_catalyst_gain
					}
				}
			}

			war_effects = {
				###### Common
				
				# Nothing

				##### Involved
				involved_parameters = {
					struggle_cb_cost_minor = yes
					truces_by_involved_or_interlopers_within_region_shorter = yes
					involved_or_interloper_wars_in_struggle_region_cheaper_piety_costs = yes
					involved_or_interloper_wars_in_struggle_region_cheaper_costs = yes
					unlocks_border_raid_casus_belli = yes
					unlocks_forced_vassalization_casus_belli = yes
				}

				involved_character_modifier = {
					same_culture_mercenary_hire_cost_mult = -0.3
					ai_war_chance = 1
					ai_war_cooldown = -0.5
					army_pursuit_mult = 0.2
					army_siege_value_mult = 0.2
					enemy_hard_casualty_modifier = 0.5
					advantage = 5 # gives the upper hand against outsiders
				}

				###### Interlopers
				interloper_parameters = {
					truces_by_involved_or_interlopers_within_region_shorter = yes
					involved_or_interloper_wars_in_struggle_region_cheaper_piety_costs = yes
					involved_or_interloper_wars_in_struggle_region_cheaper_costs = yes
				}

				interloper_character_modifier = {
					enemy_hard_casualty_modifier = 0.5
				}

				###### Uninvolved
				uninvolved_parameters = {
					claims_in_region_more_expensive_to_press_for_uninvolved = yes
				}

			}

			faith_effects = {
				###### Common
				common_parameters = {
					county_faith_conversion_in_region_proceeds_slower = yes
					#Modded
					#holy_wars_in_region_cannot_be_declared = yes # not sure if relevant?
				}

				###### Involved
				involved_parameters = {
					holy_order_can_be_created_by_dukes = yes
					interfaith_marriages_available_between_involved_characters = yes
					interfaith_marriages_between_involved_characters_costs_piety = yes
				}

				involved_character_modifier = {
					levy_reinforcement_rate_same_faith = 0.5
					domain_tax_different_faith_mult = 0.25
					holy_order_hire_cost_mult = -0.25

					opinion_of_different_faith = -10
				}

				###### Interlopers
				interloper_character_modifier = {
					holy_order_hire_cost_mult = -0.25
				}

				###### Uninvolved

				# Nothing
			}

			culture_effects = {

				###### Common
				common_parameters = {
					county_culture_conversion_in_region_proceeds_slower = yes
				}

				###### Involved
				involved_character_modifier = {
					opinion_of_different_culture = -10

					cultural_head_fascination_mult = -0.5
					cultural_head_acceptance_gain_mult = -0.5
				}
				###### Interlopers
				interloper_character_modifier = {
					cultural_head_fascination_mult = -0.25
					cultural_head_acceptance_gain_mult = -0.25
				}
				###### Uninvolved

				# Nothing
			}

			other_effects = {
				###### Common
				
				# Nothing

				###### Involved
				involved_parameters = {
					# struggle_vips_and_culture_faith_heads_may_develop_spontaneous_negative_relations = yes
					powerful_vassal_can_claim_liege_titles = yes
					unlocks_claim_throne_for_powerful_vassals = yes
					unlocks_truce_purchasing_interaction = yes
					unlocks_expedite_scheme_decision = yes
				}

				involved_character_modifier = {
					max_hostile_schemes_add = 1
				}

				involved_county_modifier = {
					development_growth_factor = -0.3
				}

				###### Interlopers
				interloper_parameters = {
					unlocks_secure_iberian_foothold_decision = yes
				}

				interloper_county_modifier = {
					county_opinion_add = -15
					tax_mult = -0.30
					development_growth_factor = -0.4
				}

				###### Uninvolved
				uninvolved_parameters = {
					unlocks_secure_iberian_foothold_decision = yes
				}

				uninvolved_county_modifier = {
					county_opinion_add = -50
					tax_mult = -0.75

					development_growth_factor = -0.5
				}
			}

			##################################################
			# Ending

			#We are listing all available decision to give players insights on how they can end the Struggle
			ending_decisions = {
				struggle_iberia_ending_hostility_decision
				struggle_iberia_ending_compromise_decision
				struggle_iberia_ending_conciliation_decision
			 }
		}

		# Compromise happens either when Hostility has gone on so long that people are sick of it, or else when Hostility has been narrowly avoided after a bout of Tension and folks're relieved; shared trauma and too much violence encourage people to calm down and live and let live.
		struggle_iberia_phase_compromise = {
			##################################################
			# General Set-Up

			background = "gfx/interface/illustrations/struggle_backgrounds/struggle_compromise_bg.dds"

			future_phases = {
				struggle_iberia_phase_opportunity = {
					catalysts = {
						catalyst_passing_of_time = minimal_struggle_catalyst_gain
						catalyst_gain_claim_on_title = minor_struggle_catalyst_gain
						catalyst_win_any_war_within_the_region = minor_struggle_catalyst_gain # Good
						catalyst_new_building_in_castle = minor_struggle_catalyst_gain # Good
						catalyst_becomes_rival_with_involved = major_struggle_catalyst_gain # Good
						catalyst_using_a_hook_on_very_important_character = medium_struggle_catalyst_gain # good
						catalyst_unnatural_death_important_character = medium_struggle_catalyst_gain
						catalyst_usurp_title = major_struggle_catalyst_gain # good
						catalyst_forced_conversion = medium_struggle_catalyst_gain
						catalyst_reveal_secret_important = major_struggle_catalyst_gain
						catalyst_broke_truce_against_important_character = massive_struggle_catalyst_gain # Cannot motivate the AI to do that without code support
					}
				}
			}

			war_effects = {
				###### Common
				common_parameters = {
					struggle_clash_restricted_to_single_county = yes
				}

				###### Involved
				involved_parameters = {
					white_peace_acceptance_between_involved_or_interloper_with_region_easier = yes
					truces_by_involved_or_interlopers_within_region_longer = yes
					struggle_cheaper_buy_truce = yes
					unlocks_enforce_truces_interaction = yes
					unlocks_iberian_reclamation_casus_belli = yes
					struggle_cb_cost_major = yes
					involved_or_interloper_diff_faith_wars_in_struggle_region_more_expensive_prestige_costs = yes
					apply_truce_when_sending_ward = yes
					invasion_conquest_war_cannot_be_declared = yes
				}

				involved_character_modifier = {
					ai_war_chance = -0.25
					ai_war_cooldown = 0.25

					levy_reinforcement_rate_friendly_territory = 0.5
					levy_reinforcement_rate_same_faith = 0.5
					garrison_size = 0.25
					defender_advantage = 5
				}
				###### Interlopers
				interloper_parameters = {
					white_peace_acceptance_between_involved_or_interloper_with_region_easier = yes
					truces_by_involved_or_interlopers_within_region_longer = yes
					involved_or_interloper_diff_faith_wars_in_struggle_region_more_expensive_prestige_costs = yes
				}

				interloper_county_modifier = {
					monthly_county_control_change_at_war_add = -0.01
					monthly_county_control_change_at_war_mult = -0.25

					defender_holding_advantage = -5
				}

				###### Uninvolved
				uninvolved_county_modifier = {
					monthly_county_control_change_at_war_add = -0.02
					monthly_county_control_change_at_war_mult = -0.5

					defender_holding_advantage = -10
				}
			}

			faith_effects = {
				###### Common
				common_parameters = {
					holy_wars_in_region_cannot_be_declared = yes
					county_faith_conversion_in_region_proceeds_slower = yes
				}

				###### Involved
				involved_parameters = {
					interfaith_marriages_available_between_involved_characters = yes
					piety_from_new_alliance = yes
					completing_building_in_temple_gives_piety = yes
					release_prisoner_diff_faith_gives_prestige = yes
					same_faith_friend_piety_gain = yes
				}

				involved_character_modifier = {
					opinion_of_different_faith = 10
				}

				###### Interlopers
				interloper_character_modifier = {
					opinion_of_different_faith = 10
				}

				###### Uninvolved

				# Nothing
			}

			culture_effects = {
				###### Common
				common_parameters = {
					county_culture_conversion_in_region_proceeds_faster = yes
				}

				###### Involved
				involved_parameters = {
					release_prisoner_diff_culture_gives_prestige = yes
				}

				involved_character_modifier = {
					cultural_head_acceptance_gain_mult = 0.5
					opinion_of_different_culture = 10
					max_learn_language_schemes_add = 1
				}

				###### Interlopers
				interloper_character_modifier = {
					opinion_of_different_culture = 5
					max_learn_language_schemes_add = 1
				}

				###### Uninvolved

				# Nothing
			}

			other_effects = {
				###### Common

				# Nothing

				###### Involved

				involved_parameters = {
					completing_building_in_castle_gives_development = yes
					granting_independence_to_non_dejure_gives_renown = yes
					struggle_grant_titles_diff_faith_culture_gives_prestige = yes
				}

				involved_county_modifier = {
					castle_holding_build_gold_cost = -0.25
					castle_holding_holding_build_gold_cost = -0.25
				}

				###### Interlopers
				interloper_character_modifier = {
					county_opinion_add = -10
					tax_mult = -0.25
				}

				###### Uninvolved
				uninvolved_county_modifier = {
					county_opinion_add = -25
					tax_mult = -0.5
				}
			}

			##################################################
			# Ending

			#We are listing all available decision to give players insights on how they can end the Struggle
			ending_decisions = {
				struggle_iberia_ending_hostility_decision
				struggle_iberia_ending_compromise_decision
				struggle_iberia_ending_conciliation_decision
			 }
		}

		# During Conciliation Phase, things have gotten so amicable that societies outside the Struggle often find relations difficult to parse; interfaith marriages & myriad cultural changes are common.
		# We s
		struggle_iberia_phase_conciliation = {
			##################################################
			# General Set-Up

			background = "gfx/interface/illustrations/struggle_backgrounds/struggle_conciliation_bg.dds"

			future_phases = {
				struggle_iberia_phase_compromise = {
					catalysts = {
						catalyst_passing_of_time = minimal_struggle_catalyst_gain
						catalyst_gain_claim_on_title = minor_struggle_catalyst_gain
						catalyst_win_any_war_within_the_region = minor_struggle_catalyst_gain # Good
						catalyst_new_building_in_castle = minor_struggle_catalyst_gain # Good
						catalyst_becomes_rival_with_involved = major_struggle_catalyst_gain # Good
						catalyst_using_a_hook_on_very_important_character = medium_struggle_catalyst_gain # good
						#- Host a Feast when having at least two different-faith vassals
						catalyst_unnatural_death_important_character = medium_struggle_catalyst_gain
						catalyst_usurp_title = major_struggle_catalyst_gain # good
						catalyst_forced_conversion = medium_struggle_catalyst_gain
						catalyst_reveal_secret_important = major_struggle_catalyst_gain
						catalyst_broke_truce_against_important_character = massive_struggle_catalyst_gain # Cannot motivate the AI to do that without code support
					}
				}
			}

			war_effects = {
				###### Common
				common_parameters = {
					invasion_conquest_war_cannot_be_declared = yes
					struggle_clash_restricted_to_single_county = yes
				}

				###### Involved

				involved_parameters = {
					struggle_cb_cost_major = yes
					unlocks_iberian_reclamation_casus_belli = yes
					struggle_cheaper_buy_truce = yes
					truces_by_involved_or_interlopers_within_region_longer = yes
				}

				involved_character_modifier = {
					ai_war_chance = -0.5
					ai_war_cooldown = 0.5
				}

				involved_county_modifier = {
					monthly_county_control_change_at_war_add = -0.01
					monthly_county_control_change_at_war_mult = -0.10
				}

				###### Interlopers
				interloper_parameters = {
					truces_by_involved_or_interlopers_within_region_longer = yes
				}

				interloper_county_modifier = {
					monthly_county_control_change_at_war_add = -0.02
					monthly_county_control_change_at_war_mult = -0.25
				}

				###### Uninvolved
				uninvolved_county_modifier = {
					monthly_county_control_change_at_war_add = -0.05
					monthly_county_control_change_at_war_mult = -0.5
				}
			}

			faith_effects = {
				###### Common
				
				# Nothing

				###### Involved
				involved_character_modifier = {
					opinion_of_different_faith = 20
					different_faith_county_opinion_mult = -0.5
					opinion_of_different_faith_liege = 10
				}

				involved_parameters = {
					unlocks_golden_age_jewish_science_decision = yes
					unlocks_build_pilgrim_roads_decision = yes
					truces_by_involved_or_interlopers_within_region_longer = yes
					county_conversion_disabled_for_involved_faiths_within_region = yes
					interfaith_marriages_available_between_involved_characters = yes
					interfaith_marriages_between_involved_characters_gives_piety = yes
					release_prisoner_diff_faith_gives_prestige = yes
					learning_languages_gives_piety = yes
					holy_wars_in_region_cannot_be_declared = yes
				}

				###### Interlopers

				# Nothing

				###### Uninvolved

				# Nothing
			}

			culture_effects = {
				###### Common
				
				# Nothing

				###### Involved
				involved_parameters = {
					easier_culture_hybridising_for_involved_and_interlopers = yes
					release_prisoner_diff_culture_gives_prestige = yes
				}

				involved_character_modifier = {
					cultural_head_acceptance_gain_mult = 0.2
					opinion_of_different_culture = 20
					learn_language_scheme_power_mult = 0.25
					owned_personal_scheme_success_chance_add = 10
					cultural_head_fascination_mult = 0.25
				}

				###### Interlopers
				interloper_parameters = {
					easier_culture_hybridising_for_involved_and_interlopers = yes
				}

				###### Uninvolved

				# Nothing
			}

			other_effects = {
				###### Common
				all_county_modifier = {
					development_growth_factor = 0.3
				}

				###### Involved
				involved_parameters = {
					# struggle_vips_and_culture_faith_heads_may_develop_spontaneous_positive_or_negative_relations = yes
					struggle_unlocks_befriend_schemes_for_everyone = yes
					unlocks_golden_age_jewish_science_decision = yes # To implement
					struggle_prestige_from_feast = yes
					struggle_gifts_involved_diff_faith_culture_leads_to_friendship = yes
					struggle_grant_titles_diff_faith_culture_to_leads_to_friendship = yes
					struggle_cannot_execute_involved_prisoners  = yes
					struggle_becoming_friend_gives_prestige = yes
					involved_form_alliances_with_each_other_easier = yes
					struggle_agents_less_likely_to_join_schemes = yes
				}

				involved_county_modifier = {
					county_opinion_add = 20
					build_speed = -0.25
					city_holding_holding_build_gold_cost = -0.25
					city_holding_build_gold_cost = -0.25
				}

				involved_character_modifier = {
					befriend_scheme_power_mult = 0.5
					hostile_scheme_resistance_add = 20
					max_personal_schemes_add = 1
				}

				###### Interlopers
				interloper_character_modifier = {
					county_opinion_add = 10
					build_speed = -0.05

					tax_mult = -0.25
				}

				###### Uninvolved

				# Really hard for them to stay here
				uninvolved_county_modifier = {
					tax_mult = -0.5
					county_opinion_add = -50
					garrison_size = -0.5
					supply_limit_mult = -0.5
				}
			}

			##################################################
			# Ending

			#We are listing all available decision to give players insights on how they can end the Struggle
			ending_decisions = {
				struggle_iberia_ending_hostility_decision
				struggle_iberia_ending_compromise_decision
				struggle_iberia_ending_conciliation_decision
			 }
		}
	}

	# AI should gift
}