﻿# Effect which selects a default location to hold a generous welcome
# celebration, saving the selected location in `scope:SAVE_AS`.
#
# scope = the council owner for whom we are picking a location.
# SAVE_AS = the scope name to which the picked province will be saved.
regula_generous_welcome_pick_default_welcome_site_effect = {
	random_realm_province = {
		limit = {
			# Only host in a location with a holding.
			has_holding = yes
		}

		weight = {
			base = 10

			modifier = {
				factor = {
					value = 10
					multiply = {
						value = 100
						subtract = county.script_county_control
						divide = 100
					}
				}
			}

			modifier = {
				factor = 10
				NOT = { culture = scope:councillor_liege.culture }
			}

			modifier = {
				factor = 10
				NOT = { faith = scope:councillor_liege.faith }
			}

			modifier = { # Recent welcomes should be less likely to repeat.
				factor = 0.1
				county = {
					has_county_modifier = regula_generous_welcome_modifier
				}
			}
		}

		save_scope_as = $SAVE_AS$
	}
}

# Creates an attendee for a generous welcome event with a given template and location.
# Character will be saved to the given scope.
#
# TEMPLATE = the template to create the character using.
# LOCATION = the province in which the event is held.
# SAVE_AS = the scope to which the character will be saved.
regula_generous_welcome_create_character_effect = {
	create_character = {
		save_scope_as = $SAVE_AS$
		template = $TEMPLATE$

		location = $LOCATION$
		culture = $LOCATION$.culture
		faith = $LOCATION$.faith
	}
}

# Effect in which ACTOR charms the given TARGET, has sex with them, and makes them
# a part of ACTOR's court.
#
# ACTOR = the character doing the charming
# TARGET = the charm target
regula_generous_welcome_charm_attendee_effect = {
	$TARGET$ = {
		fascinare_success_effect = { CHARACTER = $ACTOR$ }
	}

	$ACTOR$ = {
		regula_sex_with_target_normal = { TARGET = $TARGET$ }
		add_courtier = $TARGET$
	}
}

# Awards a configurable amount of lifestyle XP to the scoped character's active
# lifestyle.
#
# scope = the character to award
# AMOUNT = the amount of xp to award
regula_generous_welcome_add_lifestyle_xp_effect = {
	switch = {
		trigger = has_lifestyle
		learning_lifestyle = {
			add_learning_lifestyle_xp = $AMOUNT$
		}
		diplomacy_lifestyle = {
			add_diplomacy_lifestyle_xp = $AMOUNT$
		}
		stewardship_lifestyle = {
			add_stewardship_lifestyle_xp = $AMOUNT$
		}
		martial_lifestyle = {
			add_martial_lifestyle_xp = $AMOUNT$
		}
		intrigue_lifestyle = {
			add_intrigue_lifestyle_xp = $AMOUNT$
		}
		fallback = {
			add_learning_lifestyle_xp = $AMOUNT$
		}
	}
}

# Awards one of a few positive sparring modifiers to to the scoped character.
#
# scope = the character to award
regula_generous_welcome_sparring_modifier_effect = {
	if = {
		limit = {
			NOT = {
				has_character_modifier = sparring_honed_skills_modifier
			}
		}

		add_character_modifier = {
			modifier = sparring_honed_skills_modifier
			years = 5
		}
	}
	else_if = {
		limit = {
			NOT = {
				has_character_modifier = sparring_full_of_confidence_modifier
			}
		}

		add_character_modifier = {
			modifier = sparring_full_of_confidence_modifier
			years = 5
		}
	}
}
