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

	activity_group_type = activities
	sort_order = 184

	is_shown = { OR = { is_landed = yes is_landless_adventurer = yes } }
	can_start_showing_failures_only = {
		NOT = { is_activity_type_on_cooldown = activity_cagm_royal_stud }
		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.5
	max_province_icons = 8
	allow_zero_guest_invites = yes
	open_invite = no
	is_location_valid = { has_holding = yes }
	province_description = { desc = activity_cagm_royal_stud_province_desc }
	province_score = {
		value = 10
		if = { limit = { county.holder = scope:host } add = 10 }
		if = { limit = { OR = { terrain = plains terrain = drylands terrain = steppe terrain = farmlands } } add = 20 }
		if = { limit = { county = { OR = { has_county_modifier = cagm_stud_established has_county_modifier = cagm_stud_flourishing has_county_modifier = cagm_stud_renowned } } } add = 20 }
	}

	conclusion_description = {
		first_valid = {
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_horses_result_exceptional has_variable = cagm_horses_story_method_strength } } desc = cagm_horses_conclusion_exceptional_strength }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_horses_result_exceptional has_variable = cagm_horses_story_method_agility } } desc = cagm_horses_conclusion_exceptional_agility }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_horses_result_exceptional has_variable = cagm_horses_story_method_endurance } } desc = cagm_horses_conclusion_exceptional_endurance }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_horses_result_exceptional has_variable = cagm_horses_story_method_temperament } } desc = cagm_horses_conclusion_exceptional_temperament }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_horses_result_success has_variable = cagm_horses_story_method_strength } } desc = cagm_horses_conclusion_success_strength }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_horses_result_success has_variable = cagm_horses_story_method_agility } } desc = cagm_horses_conclusion_success_agility }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_horses_result_success has_variable = cagm_horses_story_method_endurance } } desc = cagm_horses_conclusion_success_endurance }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_horses_result_success has_variable = cagm_horses_story_method_temperament } } desc = cagm_horses_conclusion_success_temperament }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_horses_result_failure has_variable = cagm_horses_story_method_strength } } desc = cagm_horses_conclusion_failure_strength }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_horses_result_failure has_variable = cagm_horses_story_method_agility } } desc = cagm_horses_conclusion_failure_agility }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_horses_result_failure has_variable = cagm_horses_story_method_endurance } } desc = cagm_horses_conclusion_failure_endurance }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_horses_result_failure has_variable = cagm_horses_story_method_temperament } } desc = cagm_horses_conclusion_failure_temperament }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_horses_result_exceptional } } desc = cagm_horses_conclusion_exceptional }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_horses_result_success } } desc = cagm_horses_conclusion_success }
			triggered_desc = { trigger = { scope:activity = { has_variable = cagm_horses_result_failure } } desc = cagm_horses_conclusion_failure }
			desc = activity_cagm_royal_stud_conclusion_desc
		}
	}

	cost = { gold = { value = cagm_stud_activity_gold_cost desc = cagm_stud_activity_base_cost } }
	ui_predicted_cost = { gold = { value = cagm_stud_activity_gold_cost } }
	cooldown = { years = 2 }

	options = {
		cagm_horses_purpose = {
			cagm_horses_breed = { default = yes ai_will_do = { value = 35 if = { limit = { is_landed = yes } add = 20 } } }
			cagm_horses_cavalry = { ai_will_do = { value = 30 if = { limit = { martial >= 12 } add = 20 } } }
			cagm_horses_mount = {
				is_valid = { can_make_expensive_purchase_trigger = { PRICE = root.cagm_modest_option_gold_cost } }
				cost = { gold = { value = cagm_modest_option_gold_cost desc = cagm_horses_mount } }
				ai_will_do = { value = 25 if = { limit = { prowess >= 10 } add = 20 } }
			}
			cagm_horses_tame = {
				is_valid = { can_make_expensive_purchase_trigger = { PRICE = root.cagm_grand_option_gold_cost } }
				cost = { gold = { value = cagm_grand_option_gold_cost desc = cagm_horses_tame } }
				ai_will_do = { value = 10 if = { limit = { has_trait = brave } add = 25 } if = { limit = { has_trait = craven } multiply = 0 } }
			}
		}
		cagm_horses_handlers = {
			cagm_horses_handlers_local = { default = yes ai_will_do = { value = 50 } }
			cagm_horses_handlers_seasoned = {
				is_valid = { can_make_expensive_purchase_trigger = { PRICE = root.cagm_modest_option_gold_cost } }
				cost = { gold = { value = cagm_modest_option_gold_cost desc = cagm_horses_handlers_seasoned } }
				ai_will_do = { value = 35 }
			}
			cagm_horses_handlers_renowned = {
				is_valid = { can_make_expensive_purchase_trigger = { PRICE = root.cagm_grand_option_gold_cost } }
				cost = { gold = { value = cagm_grand_option_gold_cost desc = cagm_horses_handlers_renowned } }
				ai_will_do = { value = 15 }
			}
		}
		cagm_horses_care = {
			cagm_horses_care_ordinary = { default = yes ai_will_do = { value = 50 } }
			cagm_horses_care_selected = {
				is_valid = { can_make_expensive_purchase_trigger = { PRICE = root.cagm_modest_option_gold_cost } }
				cost = { gold = { value = cagm_modest_option_gold_cost desc = cagm_horses_care_selected } }
				ai_will_do = { value = 35 }
			}
			cagm_horses_care_royal = {
				is_valid = { can_make_expensive_purchase_trigger = { PRICE = root.cagm_grand_option_gold_cost } }
				cost = { gold = { value = cagm_grand_option_gold_cost desc = cagm_horses_care_royal } }
				ai_will_do = { value = 15 }
			}
		}
	}

	special_option_category = cagm_horses_purpose
	on_start = {
		set_variable = { name = cagm_horses_event_adjustment value = 0 }
		set_variable = { name = cagm_horses_success value = cagm_horses_success_value }
	}
	phases = {
		cagm_horses_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_horses_success value = cagm_horses_success_value }
						progress_activity_phase_after = { days = 42 }
					}
					save_scope_as = root_scope
					trigger_event = cagm_horses.0001
					trigger_event = { id = cagm_horses.0010 days = 9 }
					trigger_event = { id = cagm_horses.0020 days = 18 }
					trigger_event = { id = cagm_horses.0050 days = 23 }
					trigger_event = { id = cagm_horses.0030 days = 28 }
					trigger_event = { id = cagm_horses.0099 days = 37 }
				}
			}
		}
	}

	map_entity = "building_western_hunt_01_entity"
	background = {
		texture = "gfx/interface/illustrations/event_scenes/ep2_hunt_generic.dds"
		environment = "environment_generic_hunt"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}
	activity_window_widgets = { cagm_horses_success_widget = "activity_plugin_widgets_summary" }
	max_guest_arrival_delay_time = { months = 2 }
	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 = 55 base_activity_modifier = yes activity_guest_shared_ai_accept_modifier = yes }
	ai_check_interval = 75
	ai_will_do = {
		value = 9
		if = { limit = { martial >= 12 } add = 8 }
		if = { limit = { prowess >= 12 } add = 8 }
		if = { limit = { short_term_gold < cagm_stud_activity_gold_cost } multiply = 0 }
	}
	window_characters = {
		host = { camera = camera_body effect = { scope:host = { add_to_list = characters } } scripted_animation = { animation = marshal } }
		guest = { camera = camera_body_right effect = { every_attending_character = { limit = { this != scope:host } add_to_list = characters } } scripted_animation = { animation = admiration } }
	}
}
