﻿HRT_activity_hoftag = {
	is_shown = {
		OR = {
			is_ai = yes
			AND = {
				has_dlc_feature = tours_and_tournaments
				has_dlc_feature = advanced_activities
			}
		}
		this = title:e_hre.holder
		title:c_aachen = {
			NOT = { has_variable = HRT_dismantled }
		}
	}

	can_start_showing_failures_only = {
		is_available_adult = yes
		is_at_war = no
		custom_description = {
			text = HRT_activity_hoftag_req
			has_variable = HRT_convening_hoftag
		}
	}

	is_valid = {
		NOT = {
			has_variable = activity_invalidated
		}
		scope:host = {
			is_landed = yes
			NOT = { is_incapable = yes }
		}
	}

	on_host_death = {
		scope:activity = {
			set_variable = {
				name = activity_invalidated
			}
		}
	}

	on_invalidated = {
		# Host becomes unlanded
		if = {
			limit = {
				scope:host = { is_landed = no }
			}
			scope:activity = {
				activity_type = { save_scope_as = activity_type }
			}
			every_attending_character = {
				trigger_event = activity_system.0320
			}
		}
		if = {
			limit = {
				scope:host = { is_incapable = yes }
			}
			scope:activity = {
				activity_type = { save_scope_as = activity_type }
			}
			scope:host = {
				trigger_event = activity_system.0330
			}
			every_attending_character = {
				limit = { NOT = { this = scope:host } }
				trigger_event = activity_system.0331
			}
		}
		if = { # No one shows up
			limit = {
				has_attending_activity_guests = no
			}
			scope:activity = {
				activity_type = { save_scope_as = activity_type }
				activity_location = { save_scope_as = location }
			}
			scope:host = { trigger_event = activity_system.0100 }
		}
	}

	ai_will_do = {
		value = 50
	}

	ai_check_interval = 60

	is_location_valid = {
		has_holding = yes
	}

	ai_will_select_province = {
		value = 10
		if = {
			limit = {
				this = scope:host.capital_province
			}
			add = {
				value = 30
				desc = "Capital Province preferred"
			}
		}
	}

	max_province_icons = 1

	###################
	# PARAMETERS
	###################

	max_guest_arrival_delay_time = { months = 4 }

	is_single_location = yes

	province_filter = capital

	max_route_deviation_mult = 2.0

	cost = {
		gold = {
			add = {
				value = 0
				add = {
					value = RICE_activity_cost
					desc = hunt_base_cost
				}
			}
		}
	}

	ui_predicted_cost = {
		gold = {
			value = RICE_activity_cost

			# Make it a multiple of 5 (rounded up)
			divide = 5 
			ceiling = yes 
			multiply = 5
		}
	}
	cooldown = { days = 3650 }

	###################
	# OPTIONS
	###################

	options = {
		HRT_hoftag_type = {
			HRT_hoftag_type_default = {
				default = yes
				ai_will_do = {
					value = 15
				}
			}
		}
	}

	###################
	# PHASES
	###################

	phases = {
		HRT_hoftag_parlamentum_phase = {
			is_predefined = yes

			on_phase_active = {
				if = {
					limit = {
						this = scope:host
					}
					trigger_event = HRT_hoftag.0011
				}
			}

			on_end = {
				# Run conclusion stuff here
				# if = {
				# 	limit = { this = scope:host }
				# 	scope:activity = { progress_activity_phase_after = { weeks = 2 } }
				# }
			}
		}
	}

	###################
	# GUEST HANDLING
	###################

	max_guests = 30

	allow_zero_guest_invites = no

	guest_invite_rules = {
		rules = { }
		defaults = {
			1 = HRT_activity_invite_rule_prince_electors
			1 = HRT_activity_invite_rule_nobles
		}
	}

	can_be_activity_guest = {
		faith.religion = scope:host.faith.religion
		is_adult = yes
		is_available = yes
		in_diplomatic_range = scope:host
		OR = {
			title:e_hre = {
				any_elector = {
					this = root
				}
			}
			AND = {
				is_vassal_or_below_of = title:e_hre.holder
				highest_held_title_tier >= tier_duchy
			}
		}
	}

	host_intents = {
		intents = { HRT_press_claim_intent HRT_gather_support_intent HRT_convert_intent HRT_judgment_intent HRT_attendance_duty_intent }
		default = HRT_attendance_duty_intent
	}

	guest_intents = {
		intents = { HRT_attendance_duty_intent }
		default = HRT_attendance_duty_intent
	}

	guest_join_chance = {
		base = 10
		base_activity_modifier = yes

		# Scripted Modifiers
		activity_guest_shared_ai_accept_modifier = yes
	}

	###################
	# ACTIVITY-SPECIFIC PULSES
	###################

	pulse_actions = {

	}

	on_start = {

	}

	on_enter_passive_state = {

	}

	on_complete = {

	}

	### Graphics

	# Travel
	background = { # Bridge
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				is_riverside_province = yes
				geographical_region = world_europe
				OR = {
					terrain = farmlands
					terrain = plains
					terrain = mountains
					terrain = hills
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_bridge.dds"
		environment = "environment_travel_bridge"
		ambience = "event:/SFX/Events/Backgrounds/mountains_day"
	}
	
	background = { # Farmland, settled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				terrain = farmlands
				exists = province_owner
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_farm.dds"
		environment = "environment_travel_farmlands"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}
	background = { # Farmland, unsettled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				terrain = farmlands
				NOT = { exists = province_owner }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/farms.dds"
		environment = "environment_event_farms"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}

	background = { #Desert, settled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_desert_trigger = yes
				exists = province_owner
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_desert.dds"
		environment = "environment_travel_desert"
		ambience = "event:/SFX/Events/Backgrounds/desert_day"
	}
	background = { #Desert, unsettled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_desert_trigger = yes
				NOT = { exists = province_owner }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/desert.dds"
		environment = "environment_event_bp1_desert"
		ambience = "event:/SFX/Events/Backgrounds/desert_day"
	}

	background = { #forest snowy
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location ?= { hunt_snowy_forest_trigger = yes }
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_hunt_snowy_forest.dds"
		environment = "environment_hunt_snowy_forest"
		ambience = "event:/SFX/Events/Backgrounds/mountains_day"
	}

	background = { #forest_pine
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_forest_pine_trigger = yes
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/forest_pine.dds"
		environment = "environment_event_forest_pine"
		ambience = "event:/SFX/Events/Backgrounds/coniferous_forest_day"
	}

	background = { #forest
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_forest_trigger = yes
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/forest.dds"
		environment = "environment_event_forest"
		ambience = "event:/SFX/Events/Backgrounds/deciduous_forest_day"
	}

	background = { #mountains, settled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_mountains_trigger = yes
				exists = province_owner
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_mountains.dds"
		environment = "environment_travel_mountain_settlement"
		ambience = "event:/SFX/Events/Backgrounds/mountains_day"
	}
	background = { #mountains, unsettled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_mountains_trigger = yes
				NOT = { exists = province_owner }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/mountains.dds"
		environment = "environment_event_mountains"
		ambience = "event:/SFX/Events/Backgrounds/mountains_day"
	}

	background = { #steppe, settled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_steppe_trigger = yes
				exists = province_owner
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_steppe.dds"
		environment = "environment_travel_steppe_settlement"
		ambience = "event:/SFX/Events/Backgrounds/steppe_day"
	}
	background = { #steppe, unsettled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_steppe_trigger = yes
				NOT = { exists = province_owner }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/steppe.dds"
		environment = "environment_event_steppe"
		ambience = "event:/SFX/Events/Backgrounds/steppe_day"
	}

	background = { #drylands (formerly desert)
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_drylands_trigger = yes
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/drylands.dds"
		environment = "environment_event_desert"
		ambience = "event:/SFX/Events/Backgrounds/desert_day"
	}

	background = { #wetlands
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_wetlands_trigger = yes
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/bp1_wetlands.dds"
		environment = "environment_event_bp1_wetlands" 
		ambience = "event:/SFX/Events/Backgrounds/deciduous_forest_day"
	}

	background = { #jungle
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_jungle_trigger = yes
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/bp1_jungle.dds"
		environment = "environment_event_bp1_jungle"
		ambience = "event:/SFX/Events/Backgrounds/deciduous_forest_day"
	}

	background = { #plains, settled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_plains_trigger = yes
				exists = province_owner
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_hills.dds"
		environment = "environment_travel_hills_settlement"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}
	background = { #plains, unsettled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_plains_trigger = yes
				NOT = { exists = province_owner }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/bp1_plains.dds"
		environment = "environment_event_bp1_plains"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}

	background = { #hills, settled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_hills_trigger = yes
				exists = province_owner
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_hills.dds"
		environment = "environment_travel_hills_settlement"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}
	background = { #hills, unsettled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_hills_trigger = yes
				NOT = { exists = province_owner }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/bp1_hills.dds"
		environment = "environment_event_bp1_hills"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}

	background = { #sea
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				is_sea_province = yes
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/fp1_ocean.dds"
		environment = "environment_event_fp1_ocean"
		ambience = "event:/DLC/FP1/SFX/Events/event_ocean_longship"
	}
	# End Travel

	background = {
		texture = "gfx/interface/illustrations/event_scenes/throneroom_west.dds"
		environment = "environment_frontend_west_main"
		ambience = "event:/SFX/Events/Backgrounds/throneroom_western"
	}

	window_characters = {

		guest = {
			camera = camera_event_right
			
			effect = {
				every_attending_character = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					add_to_list = characters
				}
			}

			scripted_animation = {
				animation = idle
			}
		}

		guest = {
			camera = camera_event_center
			
			effect = {
				every_attending_character = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					add_to_list = characters
				}
			}

			scripted_animation = {
				animation = idle
			}
		}
		
		host = {
			camera = camera_event_center
			
			effect = {
				if = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					scope:host = {
						add_to_list = characters
					}
				}
			}

			scripted_animation = {
				animation = idle
			}
		}
		
		travel_host = {
			camera = camera_activity_horse
			
			effect = {
				if = {
					limit = {
						NOT = {
							scope:host.location = scope:activity.activity_location
						}
					}
					scope:host = {
						add_to_list = characters
					}
				}
			}

			scripted_animation = {
				animation = jockey_walk
			}
		}

		guest = {
			camera = camera_event_center
			
			effect = {
				every_attending_character = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					add_to_list = characters
				}
			}

			scripted_animation = {
				animation = idle
			}
		}

		guest = {
			camera = camera_event_left
			
			effect = {
				every_attending_character = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					add_to_list = characters
				}
			}

			scripted_animation = {
				animation = idle
			}
		}
	}
}