﻿# Interactions used by the Pets Expanded mod

#	gift_pet_interaction
#	debug_pets_expanded_start_pet_story_interaction
#	debug_pets_expanded_end_pet_story_interaction



# To give a pet to someone else as a gift
gift_pet_interaction = {
	category = interaction_category_friendly
	common_interaction = yes
	#interface_priority = 60
	desc = gift_pet_interaction_desc
	icon = icon_feather

	#greeting = positive
	#notification_text = GIFT_PET_PROPOSAL

	auto_accept = {
		always = yes
	}

	ai_targets = {
		ai_recipients = liege
	}
	ai_targets = {
		ai_recipients = spouses
	}
	ai_targets = {
		ai_recipients = neighboring_rulers
		ai_recipients = peer_vassals
		max = 10
	}
	ai_targets = {
		ai_recipients = vassals
		max = 10
	}
	ai_targets = {
		ai_recipients = children
		max = 10
	}
	ai_targets = {
		ai_recipients = family
		max = 20
	}
	ai_targets = {
		ai_recipients = dynasty
		max = 20
	}
	ai_target_quick_trigger = {
		#adult = yes
	}
	ai_frequency = 84

	is_shown = {
		NOT = {
			scope:recipient = scope:actor
		}
		scope:actor = {
			has_any_pet_trigger = yes
		}
	}

	is_valid_showing_failures_only = {
		scope:recipient = { is_busy_in_events_localised = yes }
		scope:actor = {
			NOT = {
				is_at_war_with = scope:recipient
			}
			is_imprisoned = no
		}
	}

	on_send = {
		scope:actor = {
			if = {
				limit = {
					has_variable = PE_gui_toggle
				}
				remove_variable = PE_gui_toggle
			}
			if = {
				limit = {
					has_variable = selected_story_type
				}
				remove_variable = selected_story_type
			}
			if = {
				limit = {
					has_variable = selected_story_scope
				}
				remove_variable = selected_story_scope
			}
		}
	}
	
	on_accept = {
		scope:actor = {
			set_variable = PE_gift_pet_gui_toggle
			set_variable = {
				name = PE_gift_pet_gui_recipient
				value = scope:recipient
			}
		}

		custom_description_no_bullet = { text = PE_gift_pet_instructions_tt }
		
	}

	auto_accept = no
	
	ai_accept = {
		base = 0
		modifier = {
			add = 100
			desc = ARTIFACT_REASON
		}
	}
	
	ai_potential = {
		is_available_at_peace_ai_adult = yes
		
	}
	
	ai_min_reply_days = 0
	ai_max_reply_days = 0
	
	ai_will_do = {
		base = 0

		modifier = {
			add = 100
			OR = {
				scope:actor = {
					any_neighboring_top_liege_realm_owner = {
						OR = {
							this = scope:recipient
							any_powerful_vassal ={
								this = scope:recipient
							}
						}
					}
				}
				scope:recipient = {
					opinion = {
						target = scope:actor
						value < 0
					}
					is_powerful_vassal_of = scope:actor
					scope:actor = { ai_rationality > 50 }
				}
				scope:recipient = {
					opinion = {
						target = scope:actor
						value < 0
					}
					scope:actor = { is_powerful_vassal_of = scope:recipient }
				}
				scope:recipient = {
					OR = {
						has_secret_relation_lover = scope:actor
						has_relation_lover = scope:actor
						has_relation_soulmate = scope:actor
						has_relation_friend = scope:actor
						has_relation_best_friend = scope:actor
					}
				}
			}
		}
		
		modifier = {
			factor = 2
			scope:recipient = {
				is_ai = no
			}
		}

		modifier = {
			factor = 0.1
			OR = {
				scope:recipient = {
					opinion = {
						target = scope:actor
						value < 0
					}
					NAND = {
						is_vassal_of = scope:actor
						scope:actor = {
							ai_rationality > 50
						}
					}
				}
				scope:actor = { has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient } }
			}
		}


		modifier = { # Do not send double-gifts
			factor = 0
			scope:recipient = {
				has_opinion_modifier = {
					target = scope:actor
					modifier = gift_pet_opinion
				}
			}
		}
	}
}


open_menagerie_interaction = {
	category = interaction_category_vassal
	common_interaction = yes
	#interface_priority = 60
	desc = open_menagerie_interaction_desc
	icon = icon_feather

	is_shown = {
		NOT = { scope:actor = scope:recipient }
		scope:actor = {
			employs_court_position = keeper_of_menagerie_court_position
			any_court_position_holder = {
				type = keeper_of_menagerie_court_position
				this = scope:recipient
			}
			NOT = { has_variable = PE_gift_pet_gui_toggle }
			NOT = { has_variable = PE_gui_toggle }
		}
	}

	is_valid_showing_failures_only = {
		scope:recipient = { is_busy_in_events_localised = yes }
		scope:actor = {
			NOT = {
				is_at_war_with = scope:recipient
			}
			is_imprisoned = no
			custom_description = {
				text = pets_expanded_has_any_pet_trigger
				OR = {
					has_any_pet_trigger = yes
					AND = {
						has_variable_list = dead_pets_list
						any_in_list = {
							variable = dead_pets_list
							count >= 1
						}
					}
				}
			}
		}
	}
	
	on_accept = {
		scope:actor = {
			toggle_pet_window_variable_effect = yes
			create_story_cycles_list_effect = yes
		}
		custom_description_no_bullet = { text = PE_open_menagerie_interaction_tt }
	}

	auto_accept = yes
}



###################
#
# DEBUG
#
###################


debug_pets_expanded_start_pet_story_interaction = {
	category = interaction_debug_main
	use_diplomatic_range = no
	ignores_pending_interaction_block = yes
	icon = dog_positive
	common_interaction = yes
	is_shown = {
		debug_only = yes
	}
	send_option = {
		flag = PE_story_cycle_cat
		localization = PE_story_cycle_cat
	}
	send_option = {
		flag = PE_story_cycle_dog
		localization = PE_story_cycle_dog
	}
	send_option = {
		flag = PE_story_cycle_badger
		localization = PE_story_cycle_badger
	}
	send_option = {
		flag = PE_story_cycle_bear
		localization = PE_story_cycle_bear
	}
	send_option = {
		flag = PE_story_cycle_falcon
		localization = PE_story_cycle_falcon
	}
	send_option = {
		flag = PE_story_cycle_ferret
		localization = PE_story_cycle_ferret
	}
	send_option = {
		flag = PE_story_cycle_fox
		localization = PE_story_cycle_fox
	}
	send_option = {
		flag = PE_story_cycle_hedgehog
		localization = PE_story_cycle_hedgehog
	}
	send_option = {
		flag = PE_story_cycle_lion
		localization = PE_story_cycle_lion
	}
	send_option = {
		flag = PE_story_cycle_monkey
		localization = PE_story_cycle_monkey
	}
	send_option = {
		flag = PE_story_cycle_nightingale
		localization = PE_story_cycle_nightingale
	}
	send_option = {
		flag = PE_story_cycle_parrot
		localization = PE_story_cycle_parrot
	}
	send_option = {
		flag = PE_story_cycle_rabbit
		localization = PE_story_cycle_rabbit
	}
	send_option = {
		flag = PE_story_cycle_squirrel
		localization = PE_story_cycle_squirrel
	}
	send_option = {
		flag = PE_story_cycle_tiger
		localization = PE_story_cycle_tiger
	}
	send_option = {
		flag = PE_story_cycle_weasel
		localization = PE_story_cycle_weasel
	}
	send_option = {
		flag = PE_story_cycle_elephant
		localization = PE_story_cycle_elephant
	}
	send_option = {
		flag = PE_story_cycle_hawk
		localization = PE_story_cycle_hawk
	}
	send_option = {
		flag = PE_story_cycle_raven
		localization = PE_story_cycle_raven
	}
	send_option = {
		flag = PE_story_cycle_horse
		localization = PE_story_cycle_horse
	}
	
	on_accept = {
		if = {
			limit = { scope:PE_story_cycle_cat = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = cat } } }
		}
		else_if = {
			limit = { scope:PE_story_cycle_dog = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = dog } } }
		}
		else_if = {
			limit = { scope:PE_story_cycle_badger = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = badger } } }
		}
		else_if = {
			limit = { scope:PE_story_cycle_bear = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = bear } } }
		}
		else_if = {
			limit = { scope:PE_story_cycle_falcon = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = falcon } } }
		}
		else_if = {
			limit = { scope:PE_story_cycle_ferret = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = ferret } } }
		}
		else_if = {
			limit = { scope:PE_story_cycle_fox = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = fox } } }
		}
		else_if = {
			limit = { scope:PE_story_cycle_hedgehog = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = hedgehog } } }
		}
		else_if = {
			limit = { scope:PE_story_cycle_lion = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = lion } } }
		}
		else_if = {
			limit = { scope:PE_story_cycle_monkey = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = monkey } } }
		}
		else_if = {
			limit = { scope:PE_story_cycle_nightingale = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = nightingale } } }
		}
		else_if = {
			limit = { scope:PE_story_cycle_parrot = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = parrot } } }
		}
		else_if = {
			limit = { scope:PE_story_cycle_rabbit = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = rabbit } } }
		}
		else_if = {
			limit = { scope:PE_story_cycle_squirrel = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = squirrel } } }
		}
		else_if = {
			limit = { scope:PE_story_cycle_tiger = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = tiger } } }
		}
		else_if = {
			limit = { scope:PE_story_cycle_weasel = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = weasel } } }
		}
		else_if = {
			limit = { scope:PE_story_cycle_elephant = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = elephant } } }
		}
		else_if = {
			limit = { scope:PE_story_cycle_hawk = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = hawk } } }
		}
		else_if = {
			limit = { scope:PE_story_cycle_raven = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = raven } } }
		}
		else_if = {
			limit = { scope:PE_story_cycle_horse = yes }
			hidden_effect = { scope:recipient = { start_pet_story_cycle_effect = { PET_TYPE = horse } } }
		}
	}
	
	auto_accept = yes
}


debug_pets_expanded_end_pet_story_interaction = {
	category = interaction_debug_main
	use_diplomatic_range = no
	ignores_pending_interaction_block = yes
	icon = dog_positive
	common_interaction = yes
	is_shown = {
		debug_only = yes
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_cat } }
		}
		flag = PE_story_cycle_cat_end
		localization = PE_story_cycle_cat_end
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_dog } }
		}
		flag = PE_story_cycle_dog_end
		localization = PE_story_cycle_dog_end
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_badger } }
		}
		flag = PE_story_cycle_badger_end
		localization = PE_story_cycle_badger_end
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_bear } }
		}
		flag = PE_story_cycle_bear_end
		localization = PE_story_cycle_bear_end
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_falcon } }
		}
		flag = PE_story_cycle_falcon_end
		localization = PE_story_cycle_falcon_end
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_ferret } }
		}
		flag = PE_story_cycle_ferret_end
		localization = PE_story_cycle_ferret_end
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_fox } }
		}
		flag = PE_story_cycle_fox_end
		localization = PE_story_cycle_fox_end
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_hedgehog } }
		}
		flag = PE_story_cycle_hedgehog_end
		localization = PE_story_cycle_hedgehog_end
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_lion } }
		}
		flag = PE_story_cycle_lion_end
		localization = PE_story_cycle_lion_end
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_monkey } }
		}
		flag = PE_story_cycle_monkey_end
		localization = PE_story_cycle_monkey_end
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_nightingale } }
		}
		flag = PE_story_cycle_nightingale_end
		localization = PE_story_cycle_nightingale_end
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_parrot } }
		}
		flag = PE_story_cycle_parrot_end
		localization = PE_story_cycle_parrot_end
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_rabbit } }
		}
		flag = PE_story_cycle_rabbit_end
		localization = PE_story_cycle_rabbit_end
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_squirrel } }
		}
		flag = PE_story_cycle_squirrel_end
		localization = PE_story_cycle_squirrel_end
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_tiger } }
		}
		flag = PE_story_cycle_tiger_end
		localization = PE_story_cycle_tiger_end
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_weasel } }
		}
		flag = PE_story_cycle_weasel_end
		localization = PE_story_cycle_weasel_end
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_elephant } }
		}
		flag = PE_story_cycle_elephant_end
		localization = PE_story_cycle_elephant_end
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_hawk } }
		}
		flag = PE_story_cycle_hawk_end
		localization = PE_story_cycle_hawk_end
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_raven } }
		}
		flag = PE_story_cycle_raven_end
		localization = PE_story_cycle_raven_end
	}
	send_option = {
		is_valid = {
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_horse } }
		}
		flag = PE_story_cycle_horse_end
		localization = PE_story_cycle_horse_end
	}
	
	on_accept = {
		if = {
			limit = { scope:PE_story_cycle_cat_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_cat }
					save_scope_as = story_to_end
				}
			}
		}
		else_if = {
			limit = { scope:PE_story_cycle_dog_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_dog }
					save_scope_as = story_to_end
				}
			}
		}
		else_if = {
			limit = { scope:PE_story_cycle_badger_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_badger }
					save_scope_as = story_to_end
				}
			}
		}
		else_if = {
			limit = { scope:PE_story_cycle_bear_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_bear }
					save_scope_as = story_to_end
				}
			}
		}
		else_if = {
			limit = { scope:PE_story_cycle_falcon_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_falcon }
					save_scope_as = story_to_end
				}
			}
		}
		else_if = {
			limit = { scope:PE_story_cycle_ferret_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_ferret }
					save_scope_as = story_to_end
				}
			}
		}
		else_if = {
			limit = { scope:PE_story_cycle_fox_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_fox }
					save_scope_as = story_to_end
				}
			}
		}
		else_if = {
			limit = { scope:PE_story_cycle_hedgehog_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_hedgehog }
					save_scope_as = story_to_end
				}
			}
		}
		else_if = {
			limit = { scope:PE_story_cycle_lion_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_lion }
					save_scope_as = story_to_end
				}
			}
		}
		else_if = {
			limit = { scope:PE_story_cycle_monkey_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_monkey }
					save_scope_as = story_to_end
				}
			}
		}
		else_if = {
			limit = { scope:PE_story_cycle_nightingale_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_nightingale }
					save_scope_as = story_to_end
				}
			}
		}
		else_if = {
			limit = { scope:PE_story_cycle_parrot_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_parrot }
					save_scope_as = story_to_end
				}
			}
		}
		else_if = {
			limit = { scope:PE_story_cycle_rabbit_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_rabbit }
					save_scope_as = story_to_end
				}
			}
		}
		else_if = {
			limit = { scope:PE_story_cycle_squirrel_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_squirrel }
					save_scope_as = story_to_end
				}
			}
		}
		else_if = {
			limit = { scope:PE_story_cycle_tiger_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_tiger }
					save_scope_as = story_to_end
				}
			}
		}
		else_if = {
			limit = { scope:PE_story_cycle_weasel_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_weasel }
					save_scope_as = story_to_end
				}
			}
		}
		else_if = {
			limit = { scope:PE_story_cycle_elephant_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_elephant }
					save_scope_as = story_to_end
				}
			}
		}
		else_if = {
			limit = { scope:PE_story_cycle_hawk_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_hawk }
					save_scope_as = story_to_end
				}
			}
		}
		else_if = {
			limit = { scope:PE_story_cycle_raven_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_raven }
					save_scope_as = story_to_end
				}
			}
		}
		else_if = {
			limit = { scope:PE_story_cycle_horse_end = yes }
			scope:recipient = {
				random_owned_story = {
					limit = { story_type = PE_story_cycle_horse }
					save_scope_as = story_to_end
				}
			}
		}

		if = {
			limit = { exists = scope:story_to_end }
			end_pet_story_cycle_from_story_scope_effect = { STORY = scope:story_to_end }
		}
	}
	
	auto_accept = yes
}



debug_give_warhorse_interaction = {
	category = interaction_debug_main
	use_diplomatic_range = no
	ignores_pending_interaction_block = yes
	icon = beast_positive
	is_shown = {
		debug_only = yes
		scope:recipient = {
			NOT = {
				any_owned_story = { story_type = story_cycle_martial_lifestyle_warhorse }
			}
		}
	}
	
	on_accept = {
		scope:recipient = {
			start_warhorse_story_cycle_effect = yes
		}
	}
	
	auto_accept = yes
}

