﻿
#Effects used in Feasts

#feast_end_guest_effect - Effect run for all guests when they leave feasts

feast_fire_correct_default_event_effect = {
	if = {
		limit = {
			this = scope:activity.activity_host
		}
		trigger_event = {
			on_action = feast_default_host_event_selection
			days = { min_feast_event_spacing max_feast_event_spacing }
		}
	}
	else = {
		trigger_event = {
			on_action = feast_default_event_selection
			days = { min_feast_event_spacing max_feast_event_spacing }
		}
	}
}

feast_end_guest_effect = {
	# Only called on the end of a *successful* feast. Feasts which are interrupted due to death, imprisonment, etc., don't get this, so put critical clean-up stuff in the activity itself.
	reveler_lifestyle_rank_up_check_effect = yes
	stress_impact = {
		base = medium_stress_loss
		gluttonous = medium_stress_impact_loss
		gregarious = medium_stress_impact_loss
		shy = medium_stress_impact_gain
	}
}

add_hosted_feast_modifier_towards_character = {
	if = {
		limit = {
			$CHARACTER$ = {
				employs_court_position = court_musician_court_position
				any_court_position_holder = {
					type = court_musician_court_position
					is_physically_able = yes
				}
			}
		}
		if = {
			limit = { # Increase the bonus slightly if musician's culture has Musicical Theorists
				$CHARACTER$ = {
					any_court_position_holder = {
						type = court_musician_court_position
						culture = { has_cultural_parameter = characters_are_better_court_musicians }
					}
				}
			}
			add_opinion = {
				target = $CHARACTER$
				modifier = feast_hosted_successful_feast_with_music
				opinion = 35
			}
		}
		else = {
			add_opinion = {
				target = $CHARACTER$
				modifier = feast_hosted_successful_feast_with_music
			}
		}
	}
	else = {
		add_opinion = {
			target = $CHARACTER$
			modifier = feast_hosted_successful_feast
		}
	}
}
# Deprecated.
hosted_successful_feast_effect = {
	if = {
		limit = {
			culture = {
				has_cultural_parameter = renown_from_feasts
			}
			exists = dynasty
		}
		dynasty = {
			add_dynasty_prestige = minor_dynasty_prestige_value
		}
	}
	scope:activity = {
		every_attending_character = {
			limit = { this != root }
			custom = every_guest_scope_tt
			add_hosted_feast_modifier_towards_character = { CHARACTER = root }
		}
	}
	reveler_lifestyle_rank_up_check_effect = yes
	hidden_effect = {
		if = {
			limit = { exists = scope:spouse }
			add_opinion = { #Your opinion of your Spouse increases, considering they did most of the work
				target = scope:spouse
				modifier = feast_spouse_hosted_successful_feast_opinion
			}
		}
	}
}

hosted_successful_feast_new_effect = {
	# Renown gain from Tradition.
	if = {
		limit = {
			culture = { has_cultural_parameter = renown_from_feasts }
		}
		dynasty ?= { add_dynasty_prestige = minor_dynasty_prestige_value }
	}
	# Piety gain from Tenets.
	if = {
		limit = {
			faith = {
				OR = {
					has_doctrine_parameter = piety_from_feasts_active
					AND = {
						has_doctrine_parameter = summer_festivals_active
						# Only during 'summer' (May 1st through July 31st).
						current_month >= 5
						current_month <= 7
					}
				}
			}
		}
		add_piety = {
			value = 0

			if = {
				limit = {
					faith = { has_doctrine_parameter = summer_festivals_active }
					# Only during 'summer' (May 1st through July 31st).
					current_month >= 5
					current_month <= 7
				}
				add = major_piety_value
			}
			if = {
				limit = {
					faith = { has_doctrine = tenet_ritual_celebrations }
				}
				add = medium_piety_value
			}
			if = {
				limit = {
					faith = { has_doctrine = tenet_hedonistic }
				}
				add = medium_piety_value
			}
			if = {
				limit = {
					has_royal_court = yes
					has_dlc_feature = royal_court
					amenity_level = { target = court_food_quality value >= 5 }
				}
				multiply = 2.5
			}
			else_if = {
				limit = {
					has_royal_court = yes
					has_dlc_feature = royal_court
					amenity_level = { target = court_food_quality value >= 4 }
				}
				multiply = 2
			}
			else_if = {
				limit = {
					has_royal_court = yes
					has_dlc_feature = royal_court
					amenity_level = { target = court_food_quality value >= 3 }
				}
				multiply = 1.5
			}
			else_if = {
				limit = {
					has_royal_court = yes
					has_dlc_feature = royal_court
					amenity_level = { target = court_food_quality value >= 2 }
				}
				multiply = 1
			}
			else_if = {
				limit = {
					has_royal_court = yes
					has_dlc_feature = royal_court
					amenity_level = { target = court_food_quality value <= 1 }
				}
				multiply = 0.5
			}

			# Always give some piety, even if you completely cheaped out.
			min = medium_piety_value
		}
	}
	# County development
	scope:activity_location.county = {
		add_county_modifier = {
			modifier = feast_recent_fest_modifier
			years = 5
		}
	}
	# Opinion with spouse (various other opinions handled elsewhere).
	hidden_effect = {
		if = {
			limit = { exists = scope:spouse }
			add_opinion = { #Your opinion of your Spouse increases, considering they did most of the work
				target = scope:spouse
				modifier = feast_spouse_hosted_successful_feast_opinion
			}
		}
	}

	# tgp_ceremonial_liege_events.0020
	if = {
		limit = {
			var:tgp_ceremonial_liege_events_0020_discount ?= flag:feast
		}
		tgp_one_up_activity_effect = yes
	}
}

hosted_successful_feast_interrupted_effect = {
	add_prestige = medium_prestige_gain
	scope:activity = {
		every_attending_character = {
			limit = {
				this != scope:host
			}
			custom = every_guest_scope_tt
			add_hosted_feast_modifier_towards_character = { CHARACTER = scope:host }
		}
	}
	reveler_lifestyle_rank_up_check_effect = yes
	hidden_effect = {
		if = {
			limit = { exists = scope:spouse }
			add_opinion = { #Your opinion of your Spouse increases, considering they did most of the work
				target = scope:spouse
				modifier = feast_spouse_hosted_successful_feast_opinion
			}
		}
	}
}
