﻿activity_cagm_vintage_gathering = {
	header_background = "gfx/interface/illustrations/activity_header_backgrounds/activity_cagm_vintage_gathering.dds"

	activity_group_type = activities
	sort_order = 191

	is_shown = { OR = { is_landed = yes is_landless_adventurer = yes } }
	can_start_showing_failures_only = {
		NOT = { is_activity_type_on_cooldown = activity_cagm_vintage_gathering }
		is_available_adult = yes
		is_imprisoned = no
		NOT = { is_incapable = yes }
	}
	is_valid = {
		scope:host = {
			is_alive = yes is_adult = yes is_imprisoned = no
			NOT = { is_incapable = yes }
			OR = { is_landed = yes is_landless_adventurer = yes }
		}
	}
	on_invalidated = {
		invalidation_imprisoned_effect = yes
		invalidation_incapable_effect = yes
		invalidation_unlanded_effect = yes
	}
	on_host_death = { invalidation_host_death_effect = yes }

	is_single_location = yes
	province_filter = domicile_realm
	ai_province_filter = domicile_domain
	max_route_deviation_mult = 1.5
	max_province_icons = 8
	allow_zero_guest_invites = yes
	open_invite = no
	is_location_valid = { has_holding = yes }
	province_description = { desc = activity_cagm_vintage_gathering_province_desc }
	province_score = {
		value = 10
		if = { limit = { county.holder = scope:host } add = 20 }
		if = { limit = { OR = { terrain = farmlands terrain = plains terrain = floodplains terrain = drylands terrain = oasis } } add = 10 }
		if = { limit = { has_building_or_higher = breweries_01 } add = 15 }
		if = { limit = { has_building_or_higher = orchards_01 } add = 15 }
	}

	conclusion_description = {
		first_valid = {
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_vintage_result_exceptional has_variable = cagm_vintage_production_local } } desc = cagm_vintage_conclusion_exceptional_local }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_vintage_result_exceptional has_variable = cagm_vintage_production_self } } desc = cagm_vintage_conclusion_exceptional_self }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_vintage_result_exceptional has_variable = cagm_vintage_production_hasty } } desc = cagm_vintage_conclusion_exceptional_hasty }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_vintage_result_exceptional has_variable = cagm_vintage_production_honey } } desc = cagm_vintage_conclusion_exceptional_honey }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_vintage_result_success has_variable = cagm_vintage_production_local } } desc = cagm_vintage_conclusion_success_local }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_vintage_result_success has_variable = cagm_vintage_production_self } } desc = cagm_vintage_conclusion_success_self }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_vintage_result_success has_variable = cagm_vintage_production_hasty } } desc = cagm_vintage_conclusion_success_hasty }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_vintage_result_success has_variable = cagm_vintage_production_honey } } desc = cagm_vintage_conclusion_success_honey }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_vintage_result_failure has_variable = cagm_vintage_production_local } } desc = cagm_vintage_conclusion_failure_local }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_vintage_result_failure has_variable = cagm_vintage_production_self } } desc = cagm_vintage_conclusion_failure_self }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_vintage_result_failure has_variable = cagm_vintage_production_hasty } } desc = cagm_vintage_conclusion_failure_hasty }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_vintage_result_failure has_variable = cagm_vintage_production_honey } } desc = cagm_vintage_conclusion_failure_honey }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_vintage_result_exceptional } } desc = cagm_vintage_conclusion_exceptional }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_vintage_result_success } } desc = cagm_vintage_conclusion_success }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_vintage_result_failure } } desc = cagm_vintage_conclusion_failure }
			desc = activity_cagm_vintage_gathering_conclusion_desc
		}
	}

	cost = { gold = { value = cagm_standard_activity_gold_cost desc = cagm_standard_activity_base_cost } }
	ui_predicted_cost = { gold = { value = cagm_standard_activity_gold_cost } }
	cooldown = { years = 2 }
	options = {
		cagm_vintage_product = {
			cagm_vintage_grape = {
				is_valid = { drinks_alcohol_trigger = yes }
				ai_will_do = { value = 25 }
			}
			cagm_vintage_grain = {
				is_valid = { drinks_alcohol_trigger = yes }
				ai_will_do = { value = 30 }
			}
			cagm_vintage_local = {
				is_valid = { drinks_alcohol_trigger = yes }
				ai_will_do = { value = 20 }
			}
			cagm_vintage_preserved = {
				default = yes
				ai_will_do = { value = 25 if = { limit = { drinks_alcohol_trigger = no } add = 100 } }
			}
		}
		cagm_vintage_purpose = {
			cagm_vintage_celebrate = { default = yes ai_will_do = { value = 30 if = { limit = { stress >= 50 } add = 25 } } }
			cagm_vintage_perfect = { ai_will_do = { value = 25 if = { limit = { learning >= 12 } add = 20 } } }
			cagm_vintage_market = { ai_will_do = { value = 25 if = { limit = { stewardship >= 12 } add = 20 } } }
			cagm_vintage_reserve = { ai_will_do = { value = 20 if = { limit = { has_trait = ambitious } add = 20 } } }
		}
		cagm_vintage_equipment = {
			cagm_vintage_equipment_local = { default = yes ai_will_do = { value = 50 } }
			cagm_vintage_equipment_sound = {
				is_valid = { can_make_expensive_purchase_trigger = { PRICE = root.cagm_modest_option_gold_cost } }
				cost = { gold = { value = cagm_modest_option_gold_cost desc = cagm_vintage_equipment_sound } }
				ai_will_do = { value = 35 }
			}
			cagm_vintage_equipment_master = {
				is_valid = { can_make_expensive_purchase_trigger = { PRICE = root.cagm_grand_option_gold_cost } }
				cost = { gold = { value = cagm_grand_option_gold_cost desc = cagm_vintage_equipment_master } }
				ai_will_do = { value = 15 }
			}
		}
	}

	special_option_category = cagm_vintage_product
	on_start = {
		set_variable = { name = cagm_vintage_event_adjustment value = 0 }
		set_variable = { name = cagm_vintage_success value = cagm_vintage_success_value }
	}
	phases = {
		cagm_vintage_phase = {
			order = 1 is_predefined = yes location_source = pickable
			on_phase_active = {
				if = {
					limit = { this = scope:host }
					scope:activity = {
						save_scope_as = activity
						activity_location = { save_scope_as = location }
						set_variable = { name = cagm_vintage_success value = cagm_vintage_success_value }
						progress_activity_phase_after = { days = 42 }
					}
					save_scope_as = root_scope
					trigger_event = cagm_vintage.0001
					trigger_event = { id = cagm_vintage.0010 days = 8 }
					trigger_event = { id = cagm_vintage.0020 days = 16 }
					trigger_event = { id = cagm_vintage.0050 days = 20 }
					trigger_event = { id = cagm_vintage.0030 days = 24 }
					trigger_event = { id = cagm_vintage.0040 days = 31 }
					trigger_event = { id = cagm_vintage.0099 days = 37 }
				}
			}
		}
	}

	map_entity = "building_western_feast_01_entity"
	background = {
		texture = "gfx/interface/illustrations/event_scenes/bp1_kitchen_western.dds"
		environment = "environment_event_feast"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}
	activity_window_widgets = { cagm_vintage_success_widget = "activity_plugin_widgets_summary" }
	max_guest_arrival_delay_time = { months = 1 }
	max_guests = 10
	can_be_activity_guest = {
		is_adult = yes is_alive = yes is_imprisoned = no
		in_diplomatic_range = scope:host
		NOT = { is_at_war_with = scope:host }
	}
	guest_invite_rules = {
		rules = { 1 = activity_invite_rule_vassals }
		defaults = { 1 = activity_invite_rule_courtiers 2 = activity_invite_rule_friends }
	}
	host_intents = { intents = { reduce_stress_intent befriend_attendee_intent } default = reduce_stress_intent }
	guest_intents = { intents = { reduce_stress_intent befriend_attendee_intent } default = reduce_stress_intent }
	guest_join_chance = { base = 60 base_activity_modifier = yes activity_guest_shared_ai_accept_modifier = yes }
	ai_check_interval = 70
	ai_will_do = {
		value = 9
		if = { limit = { stewardship >= 12 } add = 8 }
		if = { limit = { employs_court_position = court_brewmaster_court_position } add = 10 }
		if = { limit = { short_term_gold < cagm_standard_activity_gold_cost } multiply = 0 }
	}
	window_characters = {
		host = { camera = camera_body effect = { scope:host = { add_to_list = characters } } scripted_animation = { animation = personality_rational } }
		guest = { camera = camera_body_right effect = { every_attending_character = { limit = { this != scope:host } add_to_list = characters } } scripted_animation = { animation = admiration } }
	}
}
