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

	activity_group_type = activities
	sort_order = 186

	is_shown = {
		OR = { is_landed = yes is_landless_adventurer = yes }
	}

	can_start_showing_failures_only = {
		NOT = { is_activity_type_on_cooldown = activity_cagm_royal_fishing }
		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
		OR = { is_coastal = yes is_riverside_province = yes }
	}

	province_description = { desc = activity_cagm_royal_fishing_province_desc }
	province_score = {
		value = 10
		if = { limit = { is_coastal = yes } add = 10 }
		if = { limit = { is_riverside_province = yes } add = 15 }
		if = { limit = { county.holder = scope:host } add = 10 }
		if = { limit = { county = { has_county_modifier = cagm_fishing_recently_fished } } add = -30 }
	}

	conclusion_description = {
		first_valid = {
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_fishing_result_exceptional has_variable = cagm_fishing_story_method_local } } desc = cagm_fishing_conclusion_exceptional_local }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_fishing_result_exceptional has_variable = cagm_fishing_story_method_steady } } desc = cagm_fishing_conclusion_exceptional_steady }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_fishing_result_exceptional has_variable = cagm_fishing_story_method_bold } } desc = cagm_fishing_conclusion_exceptional_bold }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_fishing_result_success has_variable = cagm_fishing_story_method_local } } desc = cagm_fishing_conclusion_success_local }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_fishing_result_success has_variable = cagm_fishing_story_method_steady } } desc = cagm_fishing_conclusion_success_steady }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_fishing_result_success has_variable = cagm_fishing_story_method_bold } } desc = cagm_fishing_conclusion_success_bold }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_fishing_result_failure has_variable = cagm_fishing_story_method_local } } desc = cagm_fishing_conclusion_failure_local }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_fishing_result_failure has_variable = cagm_fishing_story_method_steady } } desc = cagm_fishing_conclusion_failure_steady }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_fishing_result_failure has_variable = cagm_fishing_story_method_bold } } desc = cagm_fishing_conclusion_failure_bold }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_fishing_result_exceptional } } desc = cagm_fishing_conclusion_exceptional }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_fishing_result_success } } desc = cagm_fishing_conclusion_success }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_fishing_result_failure } } desc = cagm_fishing_conclusion_failure }
			desc = activity_cagm_royal_fishing_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_fishing_purpose = {
			cagm_fishing_quiet = { default = yes ai_will_do = { value = 35 if = { limit = { stress >= 50 } add = 40 } } }
			cagm_fishing_contest = {
				is_valid = { can_make_expensive_purchase_trigger = { PRICE = root.cagm_modest_option_gold_cost } }
				cost = { gold = { value = cagm_modest_option_gold_cost desc = cagm_fishing_contest } }
				ai_will_do = { value = 25 if = { limit = { diplomacy >= 12 } add = 15 } }
			}
			cagm_fishing_trophy = {
				is_valid = { can_make_expensive_purchase_trigger = { PRICE = root.cagm_modest_option_gold_cost } }
				cost = { gold = { value = cagm_modest_option_gold_cost desc = cagm_fishing_trophy } }
				ai_will_do = { value = 25 if = { limit = { has_trait = ambitious } add = 15 } }
			}
			cagm_fishing_legendary = {
				is_valid = {
					custom_tooltip = {
						text = cagm_fishing_legendary_rumor_required_tt
						has_character_flag = cagm_fishing_legendary_rumor
					}
					can_make_expensive_purchase_trigger = { PRICE = root.cagm_expensive_option_gold_cost }
				}
				cost = { gold = { value = cagm_expensive_option_gold_cost desc = cagm_fishing_legendary } }
				ai_will_do = { value = 15 if = { limit = { has_trait = brave } add = 15 } }
			}
		}

		cagm_fishing_tackle = {
			cagm_fishing_tackle_simple = { default = yes ai_will_do = { value = 50 } }
			cagm_fishing_tackle_fine = {
				is_valid = { can_make_expensive_purchase_trigger = { PRICE = root.cagm_modest_option_gold_cost } }
				cost = { gold = { value = cagm_modest_option_gold_cost desc = cagm_fishing_tackle_fine } }
				ai_will_do = { value = 35 }
			}
			cagm_fishing_tackle_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_fishing_tackle_master } }
				ai_will_do = { value = 15 if = { limit = { stewardship >= 14 } add = 20 } }
			}
		}
	}

	special_option_category = cagm_fishing_purpose

	on_start = {
		set_variable = { name = cagm_fishing_event_adjustment value = 0 }
		set_variable = { name = cagm_fishing_success value = cagm_fishing_success_value }
	}

	phases = {
		cagm_fishing_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_fishing_success value = cagm_fishing_success_value }
						progress_activity_phase_after = { days = 42 }
					}
					save_scope_as = root_scope
					trigger_event = cagm_fishing.0002
					trigger_event = { id = cagm_fishing.0010 days = 9 }
					trigger_event = { id = cagm_fishing.0020 days = 18 }
					trigger_event = { id = cagm_fishing.0050 days = 23 }
					trigger_event = { id = cagm_fishing.0030 days = 28 }
					trigger_event = { id = cagm_fishing.0099 days = 37 }
				}
			}
		}
	}

	map_entity = "building_western_hunt_01_entity"
	background = {
		texture = "gfx/interface/illustrations/event_scenes/bp3_riverside.dds"
		environment = "environment_bp3_riverside"
		ambience = "event:/SFX/Events/Backgrounds/deciduous_forest_day"
	}
	activity_window_widgets = { cagm_fishing_success_widget = "activity_plugin_widgets_summary" }

	max_guest_arrival_delay_time = { months = 2 }
	max_guests = 12
	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_courtiers }
		defaults = { 1 = activity_invite_rule_friends 2 = activity_invite_rule_close_family }
	}
	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 = 60
	ai_will_do = {
		value = 12
		if = { limit = { stress >= 50 } add = 18 }
		if = { limit = { has_trait = cagm_angler } 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 = admiration } }
	}
}
