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

	activity_group_type = activities
	sort_order = 183

	is_shown = { OR = { is_landed = yes is_landless_adventurer = yes } }
	can_start_showing_failures_only = {
		NOT = { is_activity_type_on_cooldown = activity_cagm_star_vigil }
		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 = 2.0
	max_province_icons = 8
	allow_zero_guest_invites = yes
	open_invite = no
	is_location_valid = { has_holding = yes }
	province_description = { desc = activity_cagm_star_vigil_province_desc }
	province_score = {
		value = 10
		if = { limit = { county.holder = scope:host } add = 10 }
		if = { limit = { OR = { terrain = hills terrain = mountains terrain = desert_mountains terrain = drylands } } add = 20 }
	}

	conclusion_description = {
		first_valid = {
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_stars_result_exceptional has_variable = cagm_stars_story_method_tables } } desc = cagm_stars_conclusion_exceptional_tables }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_stars_result_exceptional has_variable = cagm_stars_story_method_memory } } desc = cagm_stars_conclusion_exceptional_memory }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_stars_result_exceptional has_variable = cagm_stars_story_method_alignment } } desc = cagm_stars_conclusion_exceptional_alignment }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_stars_result_success has_variable = cagm_stars_story_method_tables } } desc = cagm_stars_conclusion_success_tables }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_stars_result_success has_variable = cagm_stars_story_method_memory } } desc = cagm_stars_conclusion_success_memory }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_stars_result_success has_variable = cagm_stars_story_method_alignment } } desc = cagm_stars_conclusion_success_alignment }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_stars_result_failure has_variable = cagm_stars_story_method_tables } } desc = cagm_stars_conclusion_failure_tables }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_stars_result_failure has_variable = cagm_stars_story_method_memory } } desc = cagm_stars_conclusion_failure_memory }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_stars_result_failure has_variable = cagm_stars_story_method_alignment } } desc = cagm_stars_conclusion_failure_alignment }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_stars_result_exceptional } } desc = cagm_stars_conclusion_exceptional }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_stars_result_success } } desc = cagm_stars_conclusion_success }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_stars_result_failure } } desc = cagm_stars_conclusion_failure }
			desc = activity_cagm_star_vigil_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_stars_purpose = {
			cagm_stars_quiet = { default = yes ai_will_do = { value = 35 if = { limit = { stress >= 50 } add = 35 } } }
			cagm_stars_chart = { ai_will_do = { value = 35 if = { limit = { learning >= 12 } add = 25 } } }
			cagm_stars_omens = { ai_will_do = { value = 25 if = { limit = { has_trait = lifestyle_mystic } add = 20 } } }
			cagm_stars_wonder = {
				is_valid = {
					custom_tooltip = {
						text = cagm_stars_wonder_rumor_required_tt
						has_character_flag = cagm_stars_wonder_rumor
					}
					can_make_expensive_purchase_trigger = { PRICE = root.cagm_modest_option_gold_cost }
				}
				cost = { gold = { value = cagm_modest_option_gold_cost desc = cagm_stars_wonder } }
				ai_will_do = { value = 20 if = { limit = { learning >= 12 } add = 20 } }
			}
		}
		cagm_stars_instruments = {
			cagm_stars_instruments_naked_eye = { default = yes ai_will_do = { value = 50 } }
			cagm_stars_instruments_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_stars_instruments_sound } }
				ai_will_do = { value = 35 }
			}
			cagm_stars_instruments_finest = {
				is_valid = { can_make_expensive_purchase_trigger = { PRICE = root.cagm_grand_option_gold_cost } }
				cost = { gold = { value = cagm_grand_option_gold_cost desc = cagm_stars_instruments_finest } }
				ai_will_do = { value = 15 if = { limit = { learning >= 14 } add = 20 } }
			}
		}
	}

	special_option_category = cagm_stars_purpose
	on_start = {
		set_variable = { name = cagm_stars_event_adjustment value = 0 }
		set_variable = { name = cagm_stars_success value = cagm_stars_success_value }
	}
	phases = {
		cagm_stars_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_stars_success value = cagm_stars_success_value }
						progress_activity_phase_after = { days = 28 }
					}
					save_scope_as = root_scope
					trigger_event = cagm_stars.0001
					trigger_event = { id = cagm_stars.0010 days = 6 }
					trigger_event = { id = cagm_stars.0020 days = 12 }
					trigger_event = { id = cagm_stars.0050 days = 15 }
					trigger_event = { id = cagm_stars.0030 days = 18 }
					trigger_event = { id = cagm_stars.0099 days = 24 }
				}
			}
		}
	}

	map_entity = "building_western_hunt_01_entity"
	background = {
		texture = "gfx/interface/illustrations/event_scenes/fp3_courtyard_night.dds"
		environment = "environment_event_feast"
		ambience = "event:/SFX/Events/Backgrounds/mountains_day"
	}
	activity_window_widgets = { cagm_stars_success_widget = "activity_plugin_widgets_summary" }
	max_guest_arrival_delay_time = { months = 1 }
	max_guests = 10
	can_be_activity_guest = {
		is_alive = yes is_imprisoned = no
		OR = {
			is_adult = yes
			AND = {
				is_adult = no
				age >= 10
				OR = { is_child_of = scope:host has_relation_guardian = scope:host }
			}
		}
		in_diplomatic_range = scope:host
		NOT = { is_at_war_with = scope:host }
	}
	guest_invite_rules = {
		rules = { 1 = activity_invite_rule_close_family }
		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 = 65 base_activity_modifier = yes activity_guest_shared_ai_accept_modifier = yes }
	ai_check_interval = 60
	ai_will_do = {
		value = 10
		if = { limit = { learning >= 12 } add = 10 }
		if = { limit = { stress >= 50 } add = 10 }
		if = { limit = { has_trait = cagm_stargazer } 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 = thinking } }
		guest = { camera = camera_body_right effect = { every_attending_character = { limit = { this != scope:host } add_to_list = characters } } scripted_animation = { animation = personality_rational } }
	}
}
