﻿@camp_purpose_prestige_cost = 1000
@camp_purpose_ai_will_do_malus_t3 = -30
@camp_purpose_ai_will_do_malus_t2 = -20
@camp_purpose_ai_will_do_malus_t1 = -10
@camp_purpose_ai_will_do_bonus_t1 = 10
@camp_purpose_ai_will_do_bonus_t2 = 20
@camp_purpose_ai_will_do_bonus_t3 = 30

camp_purpose = {
	default = camp_purpose_wanderers
	flag = realm_law
	
	camp_purpose_wanderers = {
		pass_phrase =  camp_purpose_pass_phrase
		confirmation_title = camp_purpose_pass_phrase
		confirmation_button_text = camp_purpose_confirmation_button_text

		flag = uses_camp_purpose
		flag = can_change_succession_laws
		flag = can_change_purpose_for_free
		

		can_keep = { realm_law_use_camp_purpose = yes }

		pass_cost = {
			prestige = @camp_purpose_prestige_cost
		}
		
		on_pass = {
			# Remove modifiers.
			remove_law_related_modifiers_effect = yes
			# Remove inappropriate buildings.
			laamp_clear_inappropriate_buildings_effect = yes
			# Adjust flavourisation.
			remove_camp_purpose_flavourisation_variables_effect = yes
			set_variable = flavourise_camp_purpose_wanderers
			local_arbitration_boon_set_purpose_effect = {
				MODIFIER = landless_local_arbitration_wanderers_modifier
			}
		}

		ai_will_do = { value = 0 }
	}
	
	camp_purpose_mercenaries = {
		pass_phrase =  camp_purpose_pass_phrase
		confirmation_title = camp_purpose_pass_phrase
		confirmation_button_text = camp_purpose_confirmation_button_text

		flag = uses_camp_purpose
		flag = can_change_succession_laws
		flag = laamp_contracts_weight_up_mercenary
		flag = laamp_contracts_weight_up_martial
		flag = laamp_contracts_weight_up_prowess
		flag = martial_camp_purpose

		# Camp unlocks.
		flag = unlocks_baggage_train_siege_engineers
		flag = unlocks_proving_grounds_lockwagon
		flag = unlocks_camp_perimeter_palisade
		flag = unlocks_camp_perimeter_ditch

		can_keep = { realm_law_use_camp_purpose = yes }

		pass_cost = {
			prestige = {
				if = {
					limit = {
						NOT = { has_realm_law_flag = can_change_purpose_for_free }
					}
					value = @camp_purpose_prestige_cost
				}
			}
		}
		
		modifier = {
			men_at_arms_cap = 1
			embarkation_cost_mult = -0.5
			knight_limit = 8
		}
		
		on_pass = {
			# Remove modifiers.
			remove_law_related_modifiers_effect = yes
			# Remove inappropriate buildings.
			laamp_clear_inappropriate_buildings_effect = yes
			# Adjust flavourisation.
			remove_camp_purpose_flavourisation_variables_effect = yes
			set_variable = flavourise_camp_purpose_mercenaries
			local_arbitration_boon_set_purpose_effect = {
				MODIFIER = landless_local_arbitration_mercenaries_modifier
			}
		}

		ai_will_do = {
			# If we've picked a purpose, don't change it.
			if = {
				limit = {
					NOT = { has_realm_law = camp_purpose_wanderers }
				}
				value = 0
			}
			else = {
				# Traits.
				## Education.
				if = {
					limit = { has_trait = education_martial }
					add = @camp_purpose_ai_will_do_bonus_t3
				}
				## Personality.
				### Cultural traditions
				if = {
					limit = {
						culture = {
							OR = {
								has_cultural_parameter = much_more_likely_to_be_laamps
								has_cultural_parameter = more_likely_to_be_laamps
							}
						}
					}
					add = @camp_purpose_ai_will_do_bonus_t3
				}
				### Wrathful
				if = {
					limit = { has_trait = wrathful }
					add = @camp_purpose_ai_will_do_bonus_t3
				}
				### Calm
				if = {
					limit = { has_trait = calm }
					add = @camp_purpose_ai_will_do_malus_t3
				}
				### Callous
				if = {
					limit = { has_trait = callous }
					add = @camp_purpose_ai_will_do_bonus_t3
				}
				### Sadistic
				if = {
					limit = { has_trait = sadistic }
					add = @camp_purpose_ai_will_do_bonus_t3
				}
				### Compassionate
				if = {
					limit = { has_trait = compassionate }
					add = @camp_purpose_ai_will_do_malus_t3
				}
				### Brave
				if = {
					limit = { has_trait = brave }
					add = @camp_purpose_ai_will_do_bonus_t3
				}
				### Craven
				if = {
					limit = { has_trait = craven }
					add = @camp_purpose_ai_will_do_malus_t3
				}
			}
		}
	}
	
	camp_purpose_scholars = {
		pass_phrase =  camp_purpose_pass_phrase
		confirmation_title = camp_purpose_pass_phrase
		confirmation_button_text = camp_purpose_confirmation_button_text

		modifier = {
			monthly_lifestyle_xp_gain_mult = 0.2
		}
		flag = uses_camp_purpose
		flag = can_change_succession_laws
		flag = laamp_contracts_weight_up_learning
		flag = laamp_contracts_weight_up_stewardship
		flag = laamp_contracts_weight_up_diplomacy_slight
		flag = nerd_camp_purpose

		# Camp unlocks.
		flag = unlocks_baggage_train_siege_engineers
		flag = unlocks_barber_tent_reference_corpus
		flag = unlocks_barber_tent_morticians_tools
		flag = unlocks_baggage_train_scribes
		flag = unlocks_baggage_train_ascetics
		flag = unlocks_camp_fire_nightly_debates
		flag = unlocks_proving_grounds_martial_study

		can_keep = { realm_law_use_camp_purpose = yes }

		pass_cost = {
			prestige = {
				if = {
					limit = {
						NOT = { has_realm_law_flag = can_change_purpose_for_free }
					}
					value = @camp_purpose_prestige_cost
				}
			}
		}
		
		on_pass = {
			# Remove modifiers.
			remove_law_related_modifiers_effect = yes
			# Remove inappropriate buildings.
			laamp_clear_inappropriate_buildings_effect = yes
			# Adjust flavourisation.
			remove_camp_purpose_flavourisation_variables_effect = yes
			set_variable = flavourise_camp_purpose_scholars
			local_arbitration_boon_set_purpose_effect = {
				MODIFIER = landless_local_arbitration_scholars_modifier
			}
		}

		ai_will_do = {
			# If we've picked a purpose, don't change it.
			if = {
				limit = {
					NOT = { has_realm_law = camp_purpose_wanderers }
				}
				value = 0
			}
			else = {
				# Traits.
				## Education.
				if = {
					limit = { has_trait = education_learning }
					add = @camp_purpose_ai_will_do_bonus_t3
				}
				if = {
					limit = { has_trait = education_stewardship }
					add = @camp_purpose_ai_will_do_bonus_t1
				}
				## Personality.
				### Honest
				if = {
					limit = { has_trait = honest }
					add = @camp_purpose_ai_will_do_bonus_t1
				}
				### Generous
				if = {
					limit = { has_trait = generous }
					add = @camp_purpose_ai_will_do_bonus_t2
				}
				### Calm
				if = {
					limit = { has_trait = calm }
					add = @camp_purpose_ai_will_do_bonus_t2
				}
				### Wrathful
				if = {
					limit = { has_trait = wrathful }
					add = @camp_purpose_ai_will_do_malus_t2
				}
				### Eccentric
				if = {
					limit = { has_trait = eccentric }
					add = @camp_purpose_ai_will_do_bonus_t3
				}
				### Patient
				if = {
					limit = { has_trait = patient }
					add = @camp_purpose_ai_will_do_bonus_t3
				}
				### Impatient
				if = {
					limit = { has_trait = impatient }
					add = @camp_purpose_ai_will_do_malus_t3
				}
				### Shy
				if = {
					limit = { has_trait = shy }
					add = @camp_purpose_ai_will_do_bonus_t1
				}
				### Gregarious
				if = {
					limit = { has_trait = gregarious }
					add = @camp_purpose_ai_will_do_malus_t1
				}
			}	
		}
	}
	
	camp_purpose_explorers = {
		pass_phrase =  camp_purpose_pass_phrase
		confirmation_title = camp_purpose_pass_phrase
		confirmation_button_text = camp_purpose_confirmation_button_text

		modifier = {
			character_travel_speed_mult = 0.25
			coastal_sea_travel_danger = medium_sea_danger_reduction
			sea_travel_danger = medium_sea_danger_reduction
		}
		flag = uses_camp_purpose
		flag = can_change_succession_laws
		flag = laamp_contracts_weight_up_transport
		flag = laamp_contracts_weight_up_diplomacy
		flag = laamp_contracts_weight_up_intrigue
		flag = laamp_contracts_weight_up_martial_slight

		# Camp unlocks.
		flag = unlocks_supply_tent_reserve_provisions
		flag = unlocks_supply_tent_reserve_water
		flag = unlocks_supply_tent_climbing_gear
		flag = unlocks_camp_fire_local_hangers_on
		flag = unlocks_camp_perimeter_extra_watch

		can_keep = { realm_law_use_camp_purpose = yes }

		pass_cost = {
			prestige = {
				if = {
					limit = {
						NOT = { has_realm_law_flag = can_change_purpose_for_free }
					}
					value = @camp_purpose_prestige_cost
				}
			}
		}
		
		on_pass = {
			# Remove modifiers.
			remove_law_related_modifiers_effect = yes
			# Remove inappropriate buildings.
			laamp_clear_inappropriate_buildings_effect = yes
			# Adjust flavourisation.
			remove_camp_purpose_flavourisation_variables_effect = yes
			set_variable = flavourise_camp_purpose_explorers
			local_arbitration_boon_set_purpose_effect = {
				MODIFIER = landless_local_arbitration_explorers_modifier
			}
		}

		ai_will_do = {
			# If we've picked a purpose, don't change it.
			if = {
				limit = {
					NOT = { has_realm_law = camp_purpose_wanderers }
				}
				value = 0
			}
			else = {
				# Traits.
				## Education.
				if = {
					limit = { has_trait = education_diplomacy }
					add = @camp_purpose_ai_will_do_bonus_t3
				}
				if = {
					limit = { has_trait = education_stewardship }
					add = @camp_purpose_ai_will_do_bonus_t2
				}
				## Personality.
				### Diligent
				if = {
					limit = { has_trait = diligent }
					add = @camp_purpose_ai_will_do_bonus_t2
				}
				### Lazy
				if = {
					limit = { has_trait = lazy }
					add = @camp_purpose_ai_will_do_malus_t2
				}
				### Athletic
				if = {
					limit = { has_trait = athletic }
					add = @camp_purpose_ai_will_do_bonus_t3
				}
				### Brave
				if = {
					limit = { has_trait = brave }
					add = @camp_purpose_ai_will_do_bonus_t2
				}
				### Craven
				if = {
					limit = { has_trait = craven }
					add = @camp_purpose_ai_will_do_malus_t2
				}
				### Eccentric
				if = {
					limit = { has_trait = eccentric }
					add = @camp_purpose_ai_will_do_bonus_t2
				}
				### Stubborn
				if = {
					limit = { has_trait = stubborn }
					add = @camp_purpose_ai_will_do_bonus_t1
				}
				### Fickle
				if = {
					limit = { has_trait = fickle }
					add = @camp_purpose_ai_will_do_bonus_t2
				}
				### Humble
				if = {
					limit = { has_trait = humble }
					add = @camp_purpose_ai_will_do_bonus_t2
				}
				### Arrogant
				if = {
					limit = { has_trait = arrogant }
					add = @camp_purpose_ai_will_do_malus_t2
				}
			}
		}
	}
	
	camp_purpose_brigands = {
		pass_phrase =  camp_purpose_pass_phrase
		confirmation_title = camp_purpose_pass_phrase
		confirmation_button_text = camp_purpose_confirmation_button_text

		flag = uses_camp_purpose
		flag = can_change_succession_laws
		flag = laamp_contracts_weight_up_criminal
		flag = laamp_contracts_weight_up_prowess
		flag = laamp_contracts_weight_up_intrigue
		flag = martial_camp_purpose

		# Camp unlocks.
		flag = unlocks_proving_grounds_lockwagon
		flag = unlocks_barber_tent_morticians_tools
		flag = unlocks_supply_tent_subdued_gear
		flag = unlocks_baggage_train_ransom_cages
		flag = unlocks_baggage_train_negotiators
		flag = unlocks_camp_fire_juicy_rumors
		flag = unlocks_proving_grounds_the_stick_game

		can_keep = { realm_law_use_camp_purpose = yes }

		pass_cost = {
			prestige = {
				if = {
					limit = {
						NOT = { has_realm_law_flag = can_change_purpose_for_free }
					}
					value = @camp_purpose_prestige_cost
				}
			}
		}
		
		on_pass = {
			# Remove modifiers.
			remove_law_related_modifiers_effect = yes
			# Remove inappropriate buildings.
			laamp_clear_inappropriate_buildings_effect = yes
			# Adjust flavourisation.
			remove_camp_purpose_flavourisation_variables_effect = yes
			set_variable = flavourise_camp_purpose_brigands
			local_arbitration_boon_set_purpose_effect = {
				MODIFIER = landless_local_arbitration_brigands_modifier
			}
		}
		
		modifier = {
			embarkation_cost_mult = -0.5
			knight_limit = 3
		}

		ai_will_do = {
			# If we've picked a purpose, don't change it.
			if = {
				limit = {
					NOT = { has_realm_law = camp_purpose_wanderers }
				}
				value = 0
			}
			else = {
				# Traits.
				## Education.
				if = {
					limit = { has_trait = education_intrigue }
					add = @camp_purpose_ai_will_do_bonus_t3
				}
				### Cultural traditions
				if = {
					limit = {
						culture = {
							OR = {
								has_cultural_parameter = much_more_likely_to_be_laamps
								has_cultural_parameter = more_likely_to_be_laamps
							}
						}
					}
					add = @camp_purpose_ai_will_do_bonus_t3
				}
				## Personality.
				### Deceitful.
				if = {
					limit = { has_trait = deceitful }
					add = @camp_purpose_ai_will_do_bonus_t3
				}
				### Honest.
				if = {
					limit = { has_trait = honest }
					add = @camp_purpose_ai_will_do_malus_t3
				}
				### Arbitrary.
				if = {
					limit = { has_trait = arbitrary }
					add = @camp_purpose_ai_will_do_bonus_t3
				}
				### Just,
				if = {
					limit = { has_trait = just }
					add = @camp_purpose_ai_will_do_malus_t3
				}
				### Greedy + either Humble or Content.
				if = {
					limit = {
						has_trait = greedy
						OR = {
							has_trait = humble
							has_trait = content
						}
					}
					add = @camp_purpose_ai_will_do_bonus_t2
				}
				### Generous.
				if = {
					limit = { has_trait = generous }
					add = @camp_purpose_ai_will_do_malus_t2
				}
				### Arrogant.
				if = {
					limit = { has_trait = arrogant }
					add = @camp_purpose_ai_will_do_malus_t2
				}
				### Ambitious.
				if = {
					limit = { has_trait = ambitious }
					add = @camp_purpose_ai_will_do_malus_t2
				}
				### Wrathful.
				if = {
					limit = { has_trait = wrathful }
					add = @camp_purpose_ai_will_do_bonus_t1
				}
				### Calm.
				if = {
					limit = { has_trait = calm }
					add = @camp_purpose_ai_will_do_malus_t1
				}
				### Sadistic.
				if = {
					limit = { has_trait = sadistic }
					add = @camp_purpose_ai_will_do_bonus_t2
				}
				### Callous.
				if = {
					limit = { has_trait = callous }
					add = @camp_purpose_ai_will_do_bonus_t2
				}
				### Compassionate.
				if = {
					limit = { has_trait = compassionate }
					add = @camp_purpose_ai_will_do_malus_t2
				}
			}
		}
	}
	
	camp_purpose_legitimists = {
		pass_phrase =  camp_purpose_pass_phrase
		confirmation_title = camp_purpose_pass_phrase
		confirmation_button_text = camp_purpose_confirmation_button_text
		
		flag = uses_camp_purpose
		flag = can_change_succession_laws
		flag = martial_camp_purpose

		# Camp unlocks.
		flag = unlocks_baggage_train_scribes
		flag = unlocks_proving_grounds_martial_study
		flag = unlocks_baggage_train_proof_of_claims
		flag = unlocks_baggage_train_ransom_cages
		flag = unlocks_camp_fire_future_dreams
		flag = unlocks_proving_grounds_bodyguard_drills
		flag = unlocks_proving_grounds_lockwagon

		can_keep = {
			realm_law_use_camp_purpose = yes
			ep3_can_have_legitimists_camp_purpose_trigger = yes
		}

		pass_cost = {
			prestige = {
				if = {
					limit = {
						NOT = { has_realm_law_flag = can_change_purpose_for_free }
					}
					value = @camp_purpose_prestige_cost
				}
			}
		}
		
		on_pass = {
			# Remove modifiers.
			remove_law_related_modifiers_effect = yes
			# Remove inappropriate buildings.
			laamp_clear_inappropriate_buildings_effect = yes
			# Adjust flavourisation.
			remove_camp_purpose_flavourisation_variables_effect = yes
			set_variable = flavourise_camp_purpose_legitimists
			local_arbitration_boon_set_purpose_effect = {
				MODIFIER = landless_local_arbitration_legitimists_modifier
			}
		}
		
		modifier = {
			men_at_arms_cap = 1
			knight_limit = 8
		}

		ai_will_do = {
			# Weight up legitimists inherently.
			value = 100
			# If we've picked a purpose, don't change it.
			if = {
				limit = {
					NOT = { has_realm_law = camp_purpose_wanderers }
				}
				value = 0
			}
			else = {
				# Traits.
				## Education.
				if = {
					limit = {
						OR = {
							has_trait = education_diplomacy
							has_trait = education_martial
						}
					}
					add = @camp_purpose_ai_will_do_bonus_t3
				}
				## Personality.
				### Ambitious
				if = {
					limit = { has_trait = ambitious }
					add = @camp_purpose_ai_will_do_bonus_t3
				}
				### Content
				if = {
					limit = { has_trait = content }
					add = @camp_purpose_ai_will_do_malus_t3
				}
				### Arrogant
				if = {
					limit = { has_trait = arrogant }
					add = @camp_purpose_ai_will_do_bonus_t3
				}
				### Humble
				if = {
					limit = { has_trait = humble }
					add = @camp_purpose_ai_will_do_malus_t3
				}
				### Vengeful
				if = {
					limit = { has_trait = vengeful }
					add = @camp_purpose_ai_will_do_bonus_t3
				}
				### Forgiving
				if = {
					limit = { has_trait = forgiving }
					add = @camp_purpose_ai_will_do_malus_t3
				}
			}
		}
	}

	camp_purpose_regula_magistri_cult = {
		pass_phrase =  camp_purpose_pass_phrase
		confirmation_title = camp_purpose_pass_phrase
		confirmation_button_text = camp_purpose_confirmation_button_text

		modifier = {
			attraction_opinion = 10
			monthly_lifestyle_xp_gain_mult = 0.1
		}
		flag = uses_camp_purpose
		flag = can_change_succession_laws
		flag = laamp_contracts_weight_up_regula

		# Camp unlocks.
		flag = unlocks_regula_camp_buildings

		# Unlock Famuli MAA
		flag = unlocks_famuli_maa

		can_keep = {
			custom_description = {
				text = regula_player_entranced_trigger
				OR = {
					is_regula_trigger = yes
					any_secret = {
						secret_type = regula_covert_conversion
					}
				}
			}
			realm_law_use_camp_purpose = yes
		}

		pass_cost = {
			prestige = {
				if = {
					limit = {
						NOT = { has_realm_law_flag = can_change_purpose_for_free }
					}
					value = @camp_purpose_prestige_cost
				}
			}
		}
		
		on_pass = {
			# Remove modifiers.
			remove_law_related_modifiers_effect = yes
			# Remove inappropriate buildings.
			laamp_clear_inappropriate_buildings_effect = yes
			# Adjust flavourisation.
			remove_camp_purpose_flavourisation_variables_effect = yes

			# TODO, make Regula flavour
			set_variable = flavourise_camp_purpose_scholars

			local_arbitration_boon_set_purpose_effect = {
				MODIFIER = landless_local_arbitration_wanderers_modifier
			}
		}

		ai_will_do = {
			# Traits.
			## Education.
			if = {
				limit = { has_trait = education_learning }
				add = @camp_purpose_ai_will_do_bonus_t3
			}
			if = {
				limit = { has_trait = education_stewardship }
				add = @camp_purpose_ai_will_do_bonus_t1
			}
			## Personality.
			### Honest
			if = {
				limit = { has_trait = honest }
				add = @camp_purpose_ai_will_do_bonus_t1
			}
			### Generous
			if = {
				limit = { has_trait = generous }
				add = @camp_purpose_ai_will_do_bonus_t2
			}
			### Lustful
			if = {
				limit = { has_trait = lustful }
				add = @camp_purpose_ai_will_do_bonus_t2
			}
			### Chaste
			if = {
				limit = { has_trait = chaste }
				add = @camp_purpose_ai_will_do_malus_t2
			}
			### Eccentric
			if = {
				limit = { has_trait = eccentric }
				add = @camp_purpose_ai_will_do_bonus_t3
			}
			### Patient
			if = {
				limit = { has_trait = patient }
				add = @camp_purpose_ai_will_do_bonus_t3
			}
			### Impatient
			if = {
				limit = { has_trait = impatient }
				add = @camp_purpose_ai_will_do_malus_t3
			}
			### Shy
			if = {
				limit = { has_trait = shy }
				add = @camp_purpose_ai_will_do_malus_t1
			}
			### Gregarious
			if = {
				limit = { has_trait = gregarious }
				add = @camp_purpose_ai_will_do_bonus_t1
			}
			# If we've picked a purpose, don't change it.
			if = {
				limit = {
					NOT = { has_realm_law = camp_purpose_wanderers }
				}
				multiply = 0
			}
		}
	}
}