﻿######################################
# Standard actions for random events #
######################################

stewardship_lifestyle_progress_pulse = { # Fires 4 times per year
	trigger = {
		OR = {
			is_ai = no
			is_adult = yes
			has_lifestyle = stewardship_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
		}
		NOR = {
			has_character_flag = had_recent_lifestyle_ongoing_event
			has_character_flag = had_recent_lifestyle_ongoing_event_stewardship
			# 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.)
	}
}

#Ongoing events and story cycles
stewardship_lifestyle_ongoing_events = {
	trigger = {
		is_available = yes
	}

	random_on_action = {
		chance_to_happen = 10 # Roughly one event every 18 months

		80 = stewardship_lifestyle_common_events
		15 = stewardship_lifestyle_uncommon_events
		5 = stewardship_lifestyle_rare_events		
	}
}

# Characters get a Common event roughly once every 24 months (2 years). Most lifestyle events should be Common events.
stewardship_lifestyle_common_events = {
	random_events = {
		# General Events
		100 = stewardship_general.1054 # Accusations of Witchcraft
		100 = stewardship_general.5011 # Fish pond!
		100 = stewardship_general.5041 # Servant caught stealing from the household

		# Wealth Events
		100 = stewardship_wealth.1001 # Get Out of Bankruptcy Fast!
		100 = stewardship_wealth.1011 # Mint New Coins
		100 = stewardship_wealth.1021 # War Taxes
		100 = stewardship_wealth.1061 # New Acquisitions
		100 = stewardship_wealth.5001 # Purchase livestock
		100 = stewardship_wealth.5002 # Investment advice (wealth friend)

		# Domain Events
		100 = stewardship_domain.1041 # Guild Dispute
		200 = stewardship_domain.1042 # Domineering Guild
		100 = stewardship_domain.1052 # Infested Granary
		100 = stewardship_domain.1053 # Corrupt Tax Collector
		100 = stewardship_domain.1073 # Culture Clash
		100 = stewardship_domain.6001 # Marshland Clearing
		100 = stewardship_domain.6002 # Forest clearing
		100 = stewardship_domain.6011 # Haggle with stonemasons
		75 = martial_strategy.4000 # Stocking your stores or feeding your servants.

		# Duty Events
		100 = stewardship_duty.0001 # The Diplomatic Craft
		100 = stewardship_duty.0017 # Conflict at the Council
		100 = stewardship_duty.1062 # Wealth Aplenty
		100 = stewardship_duty.1068 # Patron Benefits
		100 = stewardship_duty.4010 # Convince a vassal to leave a faction
		100 = stewardship_duty.4040 # Convince a vassal to change their contract
		100 = stewardship_duty.4060 # Lower a faction's discontent during war
		100 = stewardship_duty.7001 # Resolve a war between two ai vassals
		100 = stewardship_duty.7023 # About that Favor

	}
}

# Characters get an Uncommon event roughly once every 120 months (10 years). Longer event chains and lucrative opporunities should be Uncommon events.
stewardship_lifestyle_uncommon_events = {
	random_events = {

		# Wealth Events
		100 = stewardship_wealth.1051 # Freeman's Fortune

		# Domain Events
		100 = stewardship_domain.5031 # Reduce revolt risk by being diligent
		100 = stewardship_domain_special.1001 # Bad harvest
		100 = stewardship_domain_special.1101 # Charter fair
		100 = stewardship_domain_special.1301 # Construct a road
		100 = stewardship_domain_special.3010 # Visit displeased County
		100 = stewardship_domain_special.8001 # Construct irrigation project in county

		# Duty Events
		100 = stewardship_duty.1055 # Unwanted Pregnancy
		100 = stewardship_duty.1071 # Runaway Serfs
		100 = stewardship_duty.5021 # Vassal cheating their contract
		100 = stewardship_duty_special.1201 # Map painting journey
		100 = stewardship_duty_special.2000 # Vassal Mediation

	}
	fallback = stewardship_lifestyle_common_events
}

# Characters get a Rare event roughly once every 360 months (30 years). Character-defining events and easter egg events should be Rare events.
stewardship_lifestyle_rare_events = {
	random_events = {
		100 = stewardship_domain_special.1401 # A missing village
		100 = stewardship_domain_special.1500 # Domesday Book
		50 = lifestyle_nicknames.0001 # Stewardship nickname for when the character is arrogant
		50 = lifestyle_nicknames.0002 # Stewardship nickname when the character is humble
	}
	fallback = stewardship_lifestyle_uncommon_events
}

# Special event pool for unavailable characters (imprisoned, commanding an army, infirm, etc.)
stewardship_lifestyle_unavailable_events = {
	trigger = {
		is_available = no
	}

	random_events = {
 		# WARNING: All events in this pool *MUST* have custom is_available triggers defined.
 		# Otherwise we can wind up with weird things like imprisoned characters having a strategy discussion with their army commanders out on the campaign trail.
 		chance_to_happen = 10

 		100 = stewardship_wealth.1001 # Get Out of Bankruptcy Fast!
		100 = stewardship_wealth.1021 # War Taxes
		100 = stewardship_duty.4010 # Convince a vassal to leave a faction
		100 = stewardship_duty.4060 # Lower a faction's discontent during war
	}
}

###########################################
# Custom actions for special event chains #
###########################################

#Map painting chain
map_painting_event_selection = {
	random_events = {
		100 = stewardship_duty_special.1203
		100 = stewardship_duty_special.1204
		100 = stewardship_duty_special.1205
		100 = stewardship_duty_special.1206
		100 = stewardship_duty_special.1207
		100 = stewardship_duty_special.1208
	}
}

map_painting_outcome = {
	random_events = {
		100 = stewardship_duty_special.1281
		100 = stewardship_duty_special.1282
		100 = stewardship_duty_special.1283
		100 = stewardship_duty_special.1284
		100 = stewardship_duty_special.1285
		100 = stewardship_duty_special.1286
	}
}


#Road building chain
stewardship_road_building_chain = {
	first_valid = {
		stewardship_domain_special.1392
		stewardship_domain_special.1391
	}
	fallback = stewardship_road_building_events
}

stewardship_road_building_events = {
	random_events = {
		100 = stewardship_domain_special.1311
		100 = stewardship_domain_special.1312
		100 = stewardship_domain_special.1313
		100 = stewardship_domain_special.1314
		100 = stewardship_domain_special.1315
		100 = stewardship_domain_special.1316
		100 = stewardship_domain_special.1317
		100 = stewardship_domain_special.1318
		100 = stewardship_domain_special.1319
		100 = stewardship_domain_special.1320
		100 = stewardship_domain_special.1321
		100 = stewardship_domain_special.1395
	}	
}

stewardship_lifestyle_domesday = {
	random_events = {
		100 = stewardship_domain_special.1510 # Upset Priest
		100 = stewardship_domain_special.1520 # Concerned Noble
		100 = stewardship_domain_special.1530 # Resentful Guilds
		100 = stewardship_domain_special.1540 # Bandit Attack
		100 = stewardship_domain_special.1550 # Corrupt Steward
		100 = stewardship_domain_special.1560 # Upset Merchants
	}
	fallback = stewardship_lifestyle_domesday_end # End of event chain.
}

stewardship_lifestyle_domesday_end = {
	random_events = {
		100 = stewardship_domain_special.1590
	}
}


###########################
# Mediation Story Cycle
###########################

stewardship_duty_special_2000_mediation_stage_1 = {
	random_events = {
		100 = stewardship_duty_special.2011
		100 = stewardship_duty_special.2012
		100 = stewardship_duty_special.2013
		100 = stewardship_duty_special.2014
		100 = stewardship_duty_special.2015
		#100 = stewardship_duty_special.2016
		#100 = stewardship_duty_special.2017
		100 = stewardship_duty_special.2018
		100 = stewardship_duty_special.2019
	}
}

stewardship_duty_special_2000_mediation_stage_2 = {
	random_events = {
		100 = stewardship_duty_special.2021
		100 = stewardship_duty_special.2022
		#100 = stewardship_duty_special.2023
		#100 = stewardship_duty_special.2024
		100 = stewardship_duty_special.2025
		20 = stewardship_duty_special.2026
		100 = stewardship_duty_special.2027
	}
}

stewardship_duty_special_2000_mediation_background_events = {
	random_events = {
		100 = stewardship_duty_special.2051
		100 = stewardship_duty_special.2052
		100 = stewardship_duty_special.2053
	}
}

sell_titles_side_effect_events = {
	random_events = {
		100 = sell_titles.0001 # Vassal wants Hook instead
		100 = sell_titles.0002 # Friend gives you Gold
		100 = sell_titles.0003 # Vassal thinks you generous
		100 = sell_titles.0004 # Powerful Vassal thinks you haven't done enough for them
		100 = sell_titles.0005 # Powerful Vassal reduces their obligations
		100 = sell_titles.0006 # Someone chastises you
		30 = sell_titles.1001 # A merchant has an offer
	}
}