﻿# On actions for the Pets Expanded mod

#Let's hook into the vanilla on_action and take it from there...!
random_yearly_playable_pulse = {
	on_actions = {
		pets_expanded_ongoing_pulse
	}
}

# Is triggered once a year
pets_expanded_ongoing_pulse = {
	trigger = {
		basic_is_valid_for_yearly_events_trigger = yes
	}

	on_actions = {
		pets_expanded_maintenance_on_action
		delay = { days = { 10 50 } }
		pets_expanded_keeper_of_menagerie_ongoing_events
		delay = { days = { 60 100 } }
		gain_new_pet_on_action
	}
}

pets_expanded_maintenance_on_action = {
	events = {
		pets_expanded.9990 #To prune and clean up excessive AI stories
	}
	random_events = {
		400 = 0
		100 = pets_expanded.9991 # To give courtiers modifiers or pets
	}
}

gain_new_pet_on_action = {
	trigger = {
		basic_is_valid_for_yearly_events_trigger = yes
		ai_can_get_new_pet_trigger = yes
	}
	random_events = {
		500 = 0
		50 = pets_expanded.0010 # Someone (AI) gives you a pet
		50 = pets_expanded.1001 # Get a pet
	}
}

pets_expanded_keeper_of_menagerie_ongoing_events = {
	trigger = {
		basic_is_valid_for_yearly_events_trigger = yes
		ai_can_get_new_pet_trigger = yes

		employs_court_position = keeper_of_menagerie_court_position
		any_court_position_holder = {
			type = keeper_of_menagerie_court_position
			is_physically_able = yes
		}
	}
	random_events = {
		500 = 0
		100 = pets_expanded_keeper_of_menagerie.2001 # "Should I look for animals?"
		50 = pets_expanded_keeper_of_menagerie.2011 # found animal
		#10 = pets_expanded_keeper_of_menagerie.2013 # The Keeper of the Menagerie failed to find a pet :(
		50 = pets_expanded_keeper_of_menagerie.2021 # The Keeper of the Menagerie wants money
		50 = pets_expanded_keeper_of_menagerie.2022 # The Keeper of the Menagerie suggests a show!
		50 = pets_expanded_keeper_of_menagerie.2023 # Peasants have been sneaking into the menagerie
		#50 = pets_expanded_keeper_of_menagerie.2024 # Peasant gets killed by animal
		75 = pets_expanded_keeper_of_menagerie.2031 # The Keeper of the Menagerie treats ailing pet
	}
}




################
#
# FROM THE STORY CYCLES
#
################

pets_expanded_name_pet = {
	first_valid = {
		pet_animal.0001 # Name your cat!
		pet_animal.1001 # Name your dog!
		warhorse.0001 # Name your warhorse! Choose category

		pets_expanded.0001 # Name your pet!
	}
}

pets_expanded_story_maintenance = {
	effect = {
		trigger_event = pets_expanded.9992 # To age the pet and update health
		#To prune and clean up excessive AI stories
		if = {
			limit = { is_ai = yes }
		}
		trigger_event = pets_expanded.9990
	}
	events = {  }
}

pets_expanded_ongoing_events = {
	trigger = {
		basic_is_valid_for_yearly_events_trigger = yes
	}
	random_events = {
		chance_to_happen = 75
		1000 = 0
		50 = pets_expanded.2001 # Sing with your bird
		50 = pets_expanded.2002 # Random encounter, get some gold (adapted from pet_animal.0101)

		50 = pets_expanded.2003 # Your pet charms a courtier
		50 = pets_expanded.2004 # Your pet charms a vassal
		50 = pets_expanded.2005 # Your pet insults a courtier
		50 = pets_expanded.2006 # Your pet insults a vassal

		25 = pets_expanded.2007 # Your pet is made into quills :(
		25 = pets_expanded.2008 # Bird of prey kills your rabbit/squirrel/weasel/ferret/young cat
		50 = pets_expanded.2009 # Hide from people with your shy pet
		50 = pets_expanded.2010 # Your pet exposes a courtier's/vassal's secret
		50 = pets_expanded.2011 # Your pet exposes one of your secrets!
		25 = pets_expanded.2012 # Pet brings home another pet!
		50 = pets_expanded.2013 # Pet messes up your chambers
		25 = pets_expanded.2014 # Chefs wants to cook a pet
		25 = pets_expanded.2015 # Courtier want to get a pelt
		10 = pets_expanded.2016 # Pet warns you about oncoming health issues
		10 = pets_expanded.2017 # Pet gets health issues, spend money to keep them alive?
		50 = pets_expanded.2018 # Lot's of pets but no keeper? Things can get messy

		800 = pets_expanded.2020 # Two pets are courting...!
		500 = pets_expanded.2021 # Two of your pets are getting it on

		50 = pets_expanded.2031 # Courtier complains about big scary pets roaming around
		50 = pets_expanded.2032 # Courtier complains about aggressive pets roaming around

		50 = pets_expanded.2041 # Child is spending a lot of time with a pet
		400 = pets_expanded.2044 # Pet soothes crying child
		50 = pets_expanded.2045 # Neighboring ruler is impressed by your cool pet!
		50 = pets_expanded.2051 # Vassal is impressed by your cool pet!
		50 = pets_expanded.2052 # Vassal or courtier bullies pet

		50 = pets_expanded.2071 #Pet inspires weaver!
		50 = pets_expanded.2072 #Pet inspires writer!

		25 = pets_expanded.8001 # CAT - Be inspired by pet - gain modifier
		25 = pets_expanded.8002 # DOG - Be inspired by pet - gain modifier
		25 = pets_expanded.8003 # BADGER - Be inspired by pet - gain modifier
		25 = pets_expanded.8004 # BEAR - Be inspired by pet - gain modifier
		25 = pets_expanded.8005 # FALCON - Be inspired by pet - gain modifier
		25 = pets_expanded.8006 # FERRET - Be inspired by pet - gain modifier
		25 = pets_expanded.8007 # FOX - Be inspired by pet - gain modifier
		25 = pets_expanded.8008 # HEDGEHOG - Be inspired by pet - gain modifier
		25 = pets_expanded.8009 # LION - Be inspired by pet - gain modifier
		25 = pets_expanded.8010 # MONKEY - Be inspired by pet - gain modifier
		25 = pets_expanded.8011 # NIGHTINGALE - Be inspired by pet - gain modifier
		25 = pets_expanded.8012 # PARROT - Be inspired by pet - gain modifier
		25 = pets_expanded.8013 # RABBIT - Be inspired by pet - gain modifier
		25 = pets_expanded.8014 # SQUIRREL - Be inspired by pet - gain modifier
		25 = pets_expanded.8015 # TIGER - Be inspired by pet - gain modifier
		25 = pets_expanded.8016 # WEASEL - Be inspired by pet - gain modifier
		25 = pets_expanded.8017 # ELEPHANT - Be inspired by pet - gain modifier
		25 = pets_expanded.8018 # HAWK - Be inspired by pet - gain modifier
		25 = pets_expanded.8019 # RAVEN - Be inspired by pet - gain modifier
		25 = pets_expanded.8020 # HORSE - Be inspired by pet - gain modifier

		25 = pets_expanded.9001 # Your pet randomly got pregnant! 
		2 = pets_expanded.9911 # Your pet has disappeared, probably due to your negligence

		####################
		# EVENTS FROM THE BASE GAME (some have been edited)

		50 = pets_expanded.7001 # You have two pets (adapted from pet_animal.2001)
		25 = pets_expanded.7002 # You have two pets and things don't really work out (adapted from pet_animal.2002)

		#Cat specific events from the base game
		50 = pet_animal.0104 #Chill with your cat and lose stress
		10 = pet_animal.0105 #Your cat exposes a courtier's/vassal's secret
		50 = pet_animal.6055 #Your spouse is allergic!
		50 = pet_animal.0109 #Your cat kills rodents
		50 = pet_animal.0200 #Your cat falls off a desk
		50 = pet_animal.0201 #Your cat knocks something off a shelf
		50 = pet_animal.0202 #Your cat interrupts some coitus
		50 = pet_animal.0203 #Your cat loves a random courtier
		50 = pet_animal.0204 #Your cat makes you feel better when you're sick
		50 = pet_animal.0205 #Your cat keeps interrupting you
		50 = pets_expanded.7015 #You pet your pet v.3 (adapted from pet_animal.6051)
		50 = pets_expanded.7016 #You pet your pet v.4 (adapted from pet_animal.6052)

		#Dog-specific events from the base game
		50 = pet_animal.1101 #Walk you dog, get health modifier
		50 = pet_animal.1102 #Dog runs away!
		5 = pet_animal.1108 #Your dog exposes a scheme targeting you
		50 = pet_animal.1109 #Meet another dog!
		50 = pet_animal.1113 #Bring your dog to a council meeting?
		50 = pets_expanded.7011 #You pet your pet (adapted from pet_animal.6001)
		50 = pets_expanded.7012 #You pet your pet v.2 (adapted from pet_animal.6002)
		5 = pets_expanded.7013 #Your dog finds a claim! (adapted from pet_animal.6003)
		5 = pets_expanded.7014 #Your pet lashes out D: (adapted from pet_animal.6004)
	}
}


on_siege_completion = {
	on_actions = {
		pets_expanded_on_siege_completion
	}
}

pets_expanded_on_siege_completion = {
	random_events = {
		100 = 0
		100 = pets_expanded.1010 # Siege completion: find pets
	}
}