﻿#####################
# All Life Event	#
# by BlackShip		#
#####################
# Called from code once a quarter for "playable" (count+) characters.
# Root is the character
# scope:quarter is which quarter it's for, from 1 to 4. Note that scope:quarter = 1 isn't necessarily in Q1 by calendar time
quarterly_playable_pulse = {
	on_actions = {
		delay = { days = { 14 30 } }
		ALE_stewardship_lifestyle_progress_pulse
		delay = { days = { 31 45 } }
		ALE_intrigue_lifestyle_progress_pulse
		delay = { days = { 46 60 } }
		ALE_diplomacy_lifestyle_progress_pulse
		delay = { days = { 61 75 } }
		ALE_martial_lifestyle_progress_pulse
		delay = { days = { 76 90 } }
		ALE_learning_lifestyle_progress_pulse
		delay = { days = { 1 90 } }
		ALE_wanderer_lifestyle_progress_pulse
	}
}

ALE_learning_lifestyle_progress_pulse = { # Fires 4 times per year
	trigger = {
		is_ai = no
		is_adult = yes
		NOT = { has_lifestyle = learning_lifestyle }
		is_playable_character = yes # Non-playable rulers shouldn't get lifestyle events, even if they still have a lifestyle.
		exists = capital_province # Because in rare situations landed AI rulers can end up without a capital.
		trigger_if = {
			limit = {
				is_ai = no
			}
			has_had_focus_for_days > 30
		}
		NOT = {
			# Must not currently be in a learning event chain.
			has_character_flag = is_in_learning_special_event
		}
	}

	first_valid_on_action = {
		learning_lifestyle_ongoing_events # General event pool
		learning_lifestyle_unavailable_events # Special event pool for unavailable characters (imprisoned, commanding an army, infirm, etc.)
	}
}

ALE_stewardship_lifestyle_progress_pulse = { # Fires 4 times per year
	trigger = {
		is_ai = no
		is_adult = yes
		NOT = { has_lifestyle = stewardship_lifestyle }
		is_playable_character = yes # Non-playable rulers shouldn't get lifestyle events, even if they still have a lifestyle.
		exists = capital_province # Because in rare situations landed AI rulers can end up without a capital.
		trigger_if = {
			limit = {
				is_ai = no
			}
			has_had_focus_for_days > 30
		}
		NOR = {
			# Must not currently be in a stewardship event chain.
			has_character_flag = is_in_stewardship_wealth_special_event
			has_character_flag = is_in_stewardship_domain_special_event
			has_character_flag = is_in_stewardship_duty_special_event
		}
	}

	first_valid_on_action = {
		stewardship_lifestyle_ongoing_events # General event pool
		stewardship_lifestyle_unavailable_events # Special event pool for unavailable characters (imprisoned, commanding an army, infirm, etc.)
	}
}

ALE_intrigue_lifestyle_progress_pulse = { # Fires 4 times per year
	trigger = {
		is_ai = no
		is_adult = yes
		NOT = { has_lifestyle = intrigue_lifestyle }
		is_playable_character = yes # Non-playable rulers shouldn't get lifestyle events, even if they still have a lifestyle.
		exists = capital_province # Because in rare situations landed AI rulers can end up without a capital.
		trigger_if = {
			limit = {
				is_ai = no
			}
			has_had_focus_for_days > 30
		}
		NOT = {
			# Must not currently be in a intrigue event chain.
			has_character_flag = is_in_intrigue_special_event
		}
	}

	first_valid_on_action = {
		intrigue_lifestyle_ongoing_events # General event pool
		intrigue_lifestyle_unavailable_events # Special event pool for unavailable characters (imprisoned, commanding an army, infirm, etc.)
	}
}

ALE_diplomacy_lifestyle_progress_pulse = { # Fires 4 times per year
	trigger = {
		is_ai = no
		is_adult = yes
		NOT = { has_lifestyle = diplomacy_lifestyle }
		is_playable_character = yes # Non-playable rulers shouldn't get lifestyle events, even if they still have a lifestyle.
		exists = capital_province # Because in rare situations landed AI rulers can end up without a capital.
		trigger_if = {
			limit = {
				is_ai = no
			}
			has_had_focus_for_days > 30
		}
		NOT = {
			# Must not currently be in a diplomacy event chain.
			has_character_flag = is_in_diplomacy_foreign_special_event
			has_character_flag = is_in_diplomacy_family_special_event
			has_character_flag = is_in_diplomacy_majesty_special_event
		}
	}

	first_valid_on_action = {
		diplomacy_lifestyle_ongoing_events # General event pool
		diplomacy_lifestyle_unavailable_events # Special event pool for unavailable characters (imprisoned, commanding an army, infirm, etc.)
	}
}

ALE_martial_lifestyle_progress_pulse = { # Fires 4 times per year
	trigger = {
		is_ai = no
		is_adult = yes
		NOT = { has_lifestyle = martial_lifestyle }
		is_playable_character = yes # Non-playable rulers shouldn't get lifestyle events, even if they still have a lifestyle.
		exists = capital_province # Because in rare situations landed AI rulers can end up without a capital.
		trigger_if = {
			limit = {
				is_ai = no
			}
			has_had_focus_for_days > 30
		}
		NOT = {
			# Must not currently be in a martial event chain.
			has_character_flag = is_in_martial_special_event
		}
	}

	first_valid_on_action = {
		martial_lifestyle_ongoing_events # General event pool
		martial_lifestyle_unavailable_events # Special event pool for unavailable characters (imprisoned, commanding an army, infirm, etc.)
	}
}

ALE_wanderer_lifestyle_progress_pulse = { # Fires 4 times per year
	trigger = {
		is_ai = no
		is_adult = yes
		NOT = { has_lifestyle = wanderer_lifestyle }
		is_landed = yes # Lifestyle events inherently assume you have one. Non-landed rulers shouldn't get lifestyle events, even if they still have a lifestyle.
		exists = capital_province # Because in rare situations landed AI rulers can end up without a capital.
		trigger_if = {
			limit = {
				is_ai = no
			}
			has_had_focus_for_days > 30
		}
		#NOT = {
			#has_character_flag = had_recent_lifestyle_ongoing_event

			# Must not currently be in a wanderer event chain.
			#has_character_flag = is_in_wanderer_surveyor_special_event
			#has_character_flag = is_in_wanderer_journey_special_event
			#has_character_flag = is_in_wanderer_destination_special_event
		#}
	}

	first_valid_on_action = {
		wanderer_lifestyle_ongoing_events # General event pool
		wanderer_lifestyle_unavailable_events # Special event pool for unavailable characters (imprisoned, commanding an army, infirm, etc.)
	}
}