﻿### Shared Activity Intents

reduce_stress_intent = {
	icon = reduce_stress_intent

	auto_complete = yes

	on_invalidated = { trigger_event = activity_system.0090 }

	ai_will_do = {
		value = stress
	}

	scripted_animation = {
		animation = happiness
	}
}

murder_attendee_intent = {
	icon = murder_intent

	is_shown = {
		has_dlc_feature = advanced_activities
		is_alive = yes
		is_adult = yes
		trigger_if = {
			limit = {
				OR = {
					scope:special_option ?= flag:hunt_type_standard
					scope:special_option ?= flag:hunt_type_falconry
					scope:special_option ?= flag:hunt_type_nerge
				}
			}
			can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
		}
		NOT = { scope:special_option ?= flag:hunt_type_legendary }
	}

	on_invalidated = {
		trigger_event = activity_system.0090
	}

	ai_targets = {
		ai_recipients = scheme_targets
		ai_recipients = scripted_relations
	}

	# Handle target character invalidation
	is_target_valid = {
		this != scope:target #Unop Prevent selecting yourself as intent target
		scope:target = {
			is_ai = yes
		}
		OR = {
			can_start_scheme = {
				type = murder
				target_character = scope:target
			}
			is_scheming_against = {
				type = murder
				target = scope:target
			}
		}
	}

	on_target_invalidated = {
		trigger_event = activity_system.0091
	}

	ai_will_do = {
		value = 0
		add = {
			value = root.ai_honor
			multiply = -1
		}
		add = {
			value = root.ai_compassion
			multiply = -1
		}
		if = {
			limit = {
				ai_honor >= high_positive_ai_value
			}
			add = -1000
		}
	}

	ai_target_score = {
		value = 0
		if = {
			limit = {
				has_relation_rival = scope:target
			}
			add = 25
		}
		if = {
			limit = {
				any_scheme = {
					type = murder
					scheme_target_character = scope:target
				}
			}
			add = 150
		}
	}

	scripted_animation = {
		animation = spymaster
	}
}

woo_attendee_intent = {
	icon = romance_intent

	is_shown = {
		has_dlc_feature = advanced_activities
		NOT = { scope:special_option ?= flag:hunt_type_legendary }
	}

	is_valid = { is_adult = yes }

	on_invalidated = {
		trigger_event = activity_system.0090
	}

	ai_targets = {
		ai_recipients = scheme_targets
		ai_recipients = activity_host
	}
	ai_targets = {
		ai_recipients = courtiers
		max = 10
	}
	ai_targets = {
		ai_recipients = activity_guests
		max = 10
	}
	ai_target_quick_trigger = {
		adult = yes
		attracted_to_owner = yes
		owner_attracted = yes
	}

	# Handle target character invalidation
	is_target_valid = {
		this != scope:target #Unop Prevent selecting yourself as intent target
		is_adult = yes
		scope:target = {
			is_adult = yes
			is_ai = yes
		}
		NOR = {
			this = scope:target
			has_relation_lover = scope:target
			has_relation_rival = scope:target
		}
		OR = {
			has_perk = unshackled_lust_perk
			is_attracted_to_gender_of = scope:target
		}
		# Just opt out anyone who has a partner they'd never cheat on.
		## It's possible for someone to still reach this state _after_ they become a woo target, but at least we're cutting it down to edge cases.
		OR = {
			scope:target = { might_cheat_on_every_partner_trigger = yes }
			is_consort_of = scope:target
		}
	}

	on_target_invalidated = {
		trigger_event = activity_system.0092
	}

	ai_will_do = {
		value = 50
		if = {
			limit = {
				OR = {
					has_trait = lustful
					has_trait = rakish
					is_deviant_trigger = yes
				}
			}
			add = 50
		}
		if = {
			limit = {
				might_cheat_on_every_partner_trigger = no
			}
			add = -1000
		}
	}

	ai_target_score = {
		value = 50
		if = {
			limit = {
				OR = {
					scope:target.age >= root.age_plus_10
					scope:target.age <= root.age_minus_10
				}
				NOT = { is_deviant_trigger = yes }
			}
			add = -1000
		}
		if = {
			limit = {
				is_close_or_extended_family_of = scope:target
				NOT = { is_deviant_trigger = yes }
			}
			add = -1000
		}
		if = {
			limit = {
				scope:target = { might_cheat_on_every_partner_trigger = no }
			}
			add = -49
		}
		if = {
			limit = {
				is_male = yes
				scope:target = { is_female = yes }
				scope:target.age <= scope:target.marriage_female_fertility_cutoff_age_value
				NOT = { is_deviant_trigger = yes }
			}
			add = -1000
		}
		if = {
			limit = {
				any_scheme = {
					type = seduce
					scheme_target_character = scope:target
				}
			}
			add = 150
		}
		if = {
			limit = {
				any_scheme = {
					type = courting
					scheme_target_character = scope:target
				}
			}
			add = 150
		}
		if = {
			limit = {
				has_opinion_modifier = {
					modifier = childhood_crush
					target = scope:target
				}
			}
			add = 150
		}
	}

	scripted_animation = {
		animation = flirtation
	}
}

befriend_attendee_intent = {
	icon = befriend_intent

	is_shown = {
		has_dlc_feature = advanced_activities
		NOT = { scope:special_option ?= flag:hunt_type_legendary }
	}

	on_invalidated = {
		trigger_event = activity_system.0090
	}

	ai_targets = {
		ai_recipients = liege
		ai_recipients = head_of_faith
	}
	ai_targets = {
		ai_recipients = courtiers
		max = 10
	}
	ai_targets = {
		ai_recipients = vassals
		max = 10
	}
	ai_targets = {
		ai_recipients = activity_guests
		max = 5
	}

	# Handle target character invalidation
	is_target_valid = {
		this != scope:target
		scope:target = {
			is_ai = yes
			is_adult = yes
		}
		NOR = {
			has_relation_friend = scope:target
			has_relation_rival = scope:target
		}
		can_set_relation_friend_trigger = { CHARACTER = scope:target }
	}

	on_target_invalidated = {
		trigger_event = activity_system.0091
	}

	ai_will_do = {
		value = 50
		if = {
			limit = {
				has_trait = paranoid
			}
			add = -1000
		}
	}

	ai_target_score = {
		value = 1
		if = {
			limit = {
				any_scheme = {
					type = befriend
					scheme_target_character = scope:target
				}
			}
			add = 150
		}
	}

	scripted_animation = {
		animation = admiration
	}
}

spread_legend_intent = {
	icon = intent_spread_legend

	auto_complete = yes

	is_valid = {
		custom_tooltip = {
			text = spread_legend_intent_not_valid_desc
			exists = promoted_legend
		}
	}
	
	is_shown = {
		has_dlc_feature = advanced_activities
		has_dlc_feature = legends_of_the_dead 
	}

	on_invalidated = { trigger_event = activity_system.0090 }

	ai_will_do = {
		value = 50
		if = {
			limit = {
				has_trait = arrogant
			}
			add = 100
		}
	}

	scripted_animation = {
		animation = happiness
	}
}

legitimacy_intent = {
	icon = intent_legitimacy

	auto_complete = yes

	is_valid = {
		custom_tooltip = {
			text = has_legit_intent_access_tt
			dynasty ?= { ce1_legitimacy_legacy_track_perks >= 3 }
		}
	}
	
	is_shown = {
		has_dlc_feature = advanced_activities
		has_dlc_feature = legends_of_the_dead
	}

	on_invalidated = { trigger_event = activity_system.0090 }

	ai_will_do = {
		value = 50
		if = {
			limit = {
				has_trait = arrogant
			}
			add = 100
		}
	}

	scripted_animation = {
		animation = personality_bold
	}
}

impose_obedience_intent = {
	icon = impose_obedience_intent

	is_shown = {
		has_dlc_feature = advanced_activities
		has_mpo_dlc_trigger = yes
		government_has_flag = government_is_nomadic
		is_alive = yes
		is_adult = yes
	}

	on_invalidated = {
		trigger_event = activity_system.0090
	}

	ai_targets = {
		ai_recipients = courtiers
		max = 10
	}
	ai_targets = {
		ai_recipients = vassals
		max = 10
	}

	# Handle target character invalidation
	is_target_valid = {
		scope:target = {
			is_ai = yes
			obedience_target = root
			NOT = { is_obedient_to = root }
		}
	}

	on_target_invalidated = {
		trigger_event = activity_system.0092
	}

	ai_will_do = {
		value = 0
		add = {
			value = root.ai_compassion
			multiply = -1
		}
	}

	ai_target_score = {
		value = 0
		if = {
			limit = {
				scope:target = { is_kurultai_trigger = yes }
			}
			add = 25
		}
		if = {
			limit = {
				scope:target = { is_powerful_vassal_of = root }
			}
			add = 25
		}
	}

	scripted_animation = {
		animation = menacing
	}
}
