﻿### EK NOTE: Added dynamic religious hostility

# Reactive Advice

action_reactive_advice_mercenaries = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_mercenaries }
				NOT = { any_hired_mercenary = { always = yes } }
				OR = {
					any_character_war = {
						defender_war_score < -25
						casus_belli = {
							primary_defender = root
						}
					}
					any_character_war = {
						attacker_war_score < -25
						casus_belli = {
							primary_attacker = root
						}
					}
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_mercenaries
				actor = root
			}
		}
	}
	effect = {
		start_tutorial_lesson = reactive_advice_mercenaries
	}
}

action_reactive_advice_succession = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_succession }
				has_character_flag = tutorial_reactive_advice_succession
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_succession
				actor = root
			}
		}
	}
	effect = {
		start_tutorial_lesson = reactive_advice_succession
	}
}

action_reactive_advice_bastards = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_bastards }
				has_character_flag = tutorial_reactive_advice_bastards
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_bastards
				actor = root
			}
		}
	}
	effect = {
		start_tutorial_lesson = reactive_advice_bastards
	}
}

action_reactive_advice_protecting_against_hostile_schemes = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_protecting_against_hostile_schemes }
				months_from_game_start >= 52 # Reactive Advice Queue, Position 13
				OR = {
					any_targeting_scheme = {
						is_scheme_category = hostile
					}
					AND = {
						exists = cp:councillor_spymaster
						cp:councillor_spymaster = {
							opinion = {
								target = root
								value < -20
							}
						}
					}
					NOT = { exists = cp:councillor_spymaster }
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_protecting_against_hostile_schemes
				actor = root
			}
		}
	}
	effect = {
		start_tutorial_lesson = reactive_advice_protecting_against_hostile_schemes
	}
}

action_reactive_advice_protect_against_factions = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_protect_against_factions }
				any_targeting_faction = {
					always = yes
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_protect_against_factions
				actor = root
			}
		}
	}
	effect = {
		start_tutorial_lesson = reactive_advice_protect_against_factions
	}
}

action_reactive_advice_imprisoned = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_imprisoned }
				is_imprisoned = yes
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_imprisoned
				actor = root
			}
		}
	}
	effect = {
		start_tutorial_lesson = reactive_advice_imprisoned
	}
}

action_reactive_advice_county_control = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_county_control }
				any_held_title = {
					tier = tier_county
					county_control < 80
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_county_control
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_county_control
	}
}

action_reactive_advice_bankruptcy = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_bankruptcy }
				gold < 0
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_bankruptcy
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_bankruptcy
	}
}

action_reactive_advice_rightful_liege = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_rightful_liege }
				months_from_game_start >= 40 # Reactive Advice Queue, Position 10
				is_at_war = no
				any_vassal = {
					highest_held_title_tier > 1
					is_playable_character = yes
					primary_title = {
						save_temporary_scope_as = primary_vassal_title
						trigger_if = { # Counts are only Rightful Vassals if you hold their De Jure Duchy.
							limit = {
								tier = tier_county
							}
							root = {
								any_held_title = {
									count = all
									NOT = { this = scope:primary_vassal_title.de_jure_liege }
								}
							}
						}
						trigger_else_if = { # Dukes are Rightful Vassals if you hold their De Jure Kingdom *OR* Empire.
							limit = {
								tier = tier_duchy
							}
							root = {
								any_held_title = {
									count = all
									NOT = { is_de_jure_liege_or_above_target = scope:primary_vassal_title }
								}
							}
						}
						trigger_else_if = { # Kings are only Rightful Vassals if you hold their De Jure Empire.
							limit = {
								tier = tier_kingdom
							}
							root = {
								any_held_title = {
									count = all
									NOT = { this = scope:primary_vassal_title.de_jure_liege }
								}
							}
						}
						trigger_else = {
							always = no
						}
					}
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_rightful_liege
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_rightful_liege
	}
}

action_reactive_advice_bishop_endorsement = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_bishop_endorsement }
				months_from_game_start >= 48 # Reactive Advice Queue, Position 12
				faith = { has_doctrine = doctrine_theocracy_temporal }
				exists = cp:councillor_court_chaplain
				cp:councillor_court_chaplain = {
					is_ai = yes
					opinion = {
						target = root
						value <= 0
					}
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_bishop_endorsement
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_bishop_endorsement
	}
}

action_reactive_advice_encyclopedia = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_encyclopedia }
				NOT = { has_global_variable = tutorial_current_situation_gradual_reveal_1 }
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_encyclopedia
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_encyclopedia
	}
}

action_reactive_advice_religion = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_religion }	
				OR = {
					is_widgetid_open = faith_window
					months_from_game_start >= 12 # Reactive Advice Queue, Position 3
				}
				
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_religion
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_religion
	}
}

action_reactive_advice_dynamic_culture = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_dynamic_culture }	
				OR = {
					is_widgetid_open = culture_window
					months_from_game_start >= 16 # Reactive Advice Queue, Position 4
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_dynamic_culture
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_dynamic_culture
	}
}

action_reactive_advice_fabricate_claim = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_fabricate_claim }
				is_at_war = no
				#NOT = { any_claim = { always = yes } }
				NOT = {
					any_neighboring_and_across_water_top_liege_realm_owner = {
						root = {
							# Must have a valid display CB.
							has_any_display_cb_on = prev
							
							# Can be suggested at most for rulers 1 tier above (e.g., Counts can have Dukes suggested, but never Kings.)
							tier_difference = {
								target = prev
								value >= -1
							}

							# Must not be allied to or have truce with recipient.
							NOR = {
								is_allied_to = prev
								has_truce = prev
							}
						}	
					}
				}
				any_character_to_title_neighboring_county = {
					exists = this
					save_temporary_scope_as = this_title
					root = {
						NOT = { has_claim_on = scope:this_title } # We do not already have a claim on this county.
						NOT = {
							any_claim = {
								is_de_jure_liege_or_above_target = scope:this_title # We do not already have a claim on a title which includes this county.
							}
						}
						NOT = {
							any_held_title = {
								is_de_jure_liege_or_above_target = scope:this_title # County does not already belong to us De Jure (because then we already have a CB for it).
							}
						}
						### EK EDIT: Hostility now scales between 0 and 100
						NOT = {
							faith = {
								faith_hostility_level = {
									target = scope:this_title.holder.top_liege.faith
									value >= faith_hostile_level # Holy Wars generally allowed in this case, so we don't need to fabricate.
								}
							}
						}
						NOR = {
							# Don't fabricate claims on our allies!
							is_allied_to = scope:this_title.holder
							is_allied_to = scope:this_title.holder.top_liege
						}
					}	
					
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_fabricate_claim
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_fabricate_claim
	}
}

action_reactive_advice_education = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				months_from_game_start >= 56 # Reactive Advice Queue, Position 14

				should_show_tutorial_alert = { LESSON = reactive_advice_education }
				is_at_war = no
				exists = player_heir
				player_heir = {
					dynasty = root.dynasty
					is_adult = no
					num_of_relation_guardian = 0
					exists = liege
					liege = root
					root = {
						is_character_interaction_valid = {
							recipient = prev
							interaction = educate_child_interaction
						}
					}
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_education
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_education
	}
}

action_reactive_advice_tooltip_modes = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_tooltip_modes }
				months_from_game_start >= 4 # Reactive Advice Queue, Position 1
				is_at_war = no
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_tooltip_modes
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_tooltip_modes
	}
}

action_perk_bonus_cap_modes = {
	type = tutorial
	icon = generic_reactive_advice
	
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_perk_bonus_cap }
				OR = {
					AND = {
						exists = var:current_sound_foundations_value
						var:current_sound_foundations_value >= sound_foundations_max
					}
					AND = {
						exists = var:current_embassies_perk_value
						var:current_embassies_perk_value >= embassies_max
					}
				}
			}
			try_create_important_action = {
				important_action_type = action_perk_bonus_cap_modes
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_perk_bonus_cap
	}
}

action_reactive_advice_varangian_adventure = {
	type = tutorial
	icon = generic_reactive_advice
	
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_varangian_adventure }
				any_independent_ruler = {
					in_diplomatic_range = root
					save_temporary_scope_as = target_ruler
					root = {
						has_cb_on = {
							target = scope:target_ruler
							cb = fp1_varangian_adventurer_conquest
						}
					}
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_varangian_adventure
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_varangian_adventure
	}
}

action_reactive_advice_court_positions = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_court_positions }	
				OR = {
					OR = {
						is_widgetid_open = court_positions_subtab_tutorial_uses_this
						months_from_game_start >= 32 # Reactive Advice Queue, Position 8
					}
					has_character_flag = force_court_positions_tutorial # For the Quick Tutorial
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_court_positions
				actor = root
				recipient = this
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_court_positions
	}
}

action_reactive_advice_artifact_inventory = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_artifact_inventory }

				OR = {
					is_widgetid_open = inventory_view
					months_from_game_start >= 36 # Reactive Advice Queue, Position 9
				}

				any_character_artifact = {
					NOR = {
						artifact_slot_type = sculpture
						artifact_slot_type = pedestal
						artifact_slot_type = wall_big
						artifact_slot_type = wall_small
						artifact_slot_type = throne
						artifact_slot_type = book
					}
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_artifact_inventory
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_artifact_inventory 
	}
}


action_reactive_advice_tours_picking_vassals = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_tours_picking_vassals }	
				is_widgetid_open = "multi_destination_selection"
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_tours_picking_vassals
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_tours_picking_vassals
	}
}


action_reactive_advice_regency_for_liege = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_regency_for_liege }	
				has_active_diarchy = yes
				OR = {
					is_widgetid_open = diarchy_window
					months_from_game_start >= 28 # Reactive Advice Queue, Position 7
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_regency_for_liege
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_regency_for_liege
	}
}

action_reactive_advice_regency_for_regent = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_regency_for_regent }	
				is_diarch = yes
				OR = {
					is_widgetid_open = diarchy_window
					months_from_game_start >= 28 # Reactive Advice Queue, Position 7
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_regency_for_regent
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_regency_for_regent
	}
}

action_reactive_advice_set_future_regent = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_set_future_regent }	
				OR = {
					is_widgetid_open = diarchy_window
					months_from_game_start >= 64 # Reactive Advice Queue, Position 16
				}
				has_active_diarchy = no
				is_landless_adventurer = no
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_set_future_regent
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_set_future_regent
	}
}

action_reactive_advice_travel_planning = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_travel_planning }	
				is_travelling = no
				OR = {
					is_widgetid_open = "travel_planning_tutorial_uses_this_1"
					is_widgetid_open = "travel_planning_tutorial_uses_this_2"
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_travel_planning
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_travel_planning
	}
}

action_reactive_advice_house_unity = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_house_unity }	
				OR = {
					is_widgetid_open = dynasty_house_view
					months_from_game_start >= 24 # Reactive Advice Queue, Position 6
				}

				house = { has_house_unity = yes }
				
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_house_unity
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_house_unity
	}
}

action_reactive_advice_tax_collector = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				OR = {
					is_widgetid_open = window_manage_tax_slots
					months_from_game_start >= 20 # Reactive Advice Queue, Position 5
				}

				should_show_tutorial_alert = { LESSON = reactive_advice_tax_collector }
				
				government_has_flag = government_is_clan
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_tax_collector
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_tax_collector
	}
}

action_reactive_advice_legitimacy = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				has_legitimacy = yes
				should_show_tutorial_alert = { LESSON = reactive_advice_legitimacy }
				NOT = { has_global_variable = tutorial_current_situation_gradual_reveal_3 }
				months_from_game_start >= 44 # Reactive Advice Queue, Position 11
			}

			try_create_important_action = {
				important_action_type = action_reactive_advice_legitimacy
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_legitimacy
	}
}

action_reactive_advice_epidemics = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_epidemics }

				any_sub_realm_county = {
					any_county_province = {
						any_province_epidemic = {
							count >= 1
						}
					}
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_epidemics
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_epidemics
	}
}

action_reactive_advice_plague_resistance = {
	type = tutorial
	icon = generic_reactive_advice

	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_plague_resistance }

				any_sub_realm_county = {
					any_county_province = {
						any_province_epidemic = {
							count >= 1
						}
					}
				}
			}

			try_create_important_action = {
				important_action_type = action_reactive_advice_plague_resistance
				recipient = this
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_plague_resistance
	}
}

action_reactive_advice_tutorial_schemes = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_tutorial_schemes }
				has_global_variable = tutorial_completed # only show in post-tutorial
				has_owned_scheme = no # show only if you've started a scheme
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_tutorial_schemes
				recipient = this
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_tutorial_schemes
	}
}

action_reactive_advice_tutorial_war = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_tutorial_war }
				AND = {
					is_at_war = yes # show only if you're at war
					has_global_variable = tutorial_completed
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_tutorial_war
				recipient = this
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_tutorial_war
	}
}

action_reactive_advice_favorite_child = {
	type = tutorial
	icon = generic_reactive_advice

	check_create_action = {
		if = {
			limit = {
				months_from_game_start >= 68 # Reactive Advice Queue, Position 17
				should_show_tutorial_alert = { LESSON = reactive_advice_favorite_child }
				NOT = {
					any_relation = { type = favorite_child }
				}
				exists = dynasty
				any_close_family_member = {
					count >= 2
					is_alive = yes
					dynasty ?= root.dynasty
					OR = {
						is_child_of = root
						is_grandchild_of = root
						is_great_grandchild_of = root
					}
				}
			}

			try_create_important_action = {
				important_action_type = action_reactive_advice_favorite_child
				recipient = this
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_favorite_child
	}
}

action_reactive_advice_army_automation = {
	type = tutorial
	icon = generic_reactive_advice

	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_army_automation }
				
				OR = {
					months_from_game_start >= 60 # Reactive Advice Queue, Position 15
					participated_wars >= 2 # you are starting your 2nd war
				}

			}

			try_create_important_action = {
				important_action_type = action_reactive_advice_army_automation
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_army_automation
	}
}




# EP3 RA

action_reactive_advice_landless_adventurer = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_landless_adventurer }
				is_landless_adventurer = yes
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_landless_adventurer
				recipient = this
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_landless_adventurer
	}
}

action_reactive_advice_admin_gov = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				OR = {
					is_widgetid_open = government_administration_window
					months_from_game_start >= 20 # Reactive Advice Queue, Position 5
				}

				should_show_tutorial_alert = { LESSON = reactive_advice_admin_gov }
				has_government = administrative_government
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_admin_gov
				recipient = this
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_admin_gov
	}
}

action_reactive_advice_admin_gov_troops = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_admin_gov_troops }
				AND = {
					has_government = administrative_government
					
					OR = {
						months_from_game_start >= 24 # Reactive Advice Queue, Position 6
						is_at_war = yes
						is_widgetid_open = military_view
						any_liege_or_above = { is_at_war = yes }
					}
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_admin_gov_troops
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_admin_gov_troops
	}
}


action_reactive_advice_agent_scheme_rework = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"
	check_create_action = {
		if = {
			limit = {
				should_show_tutorial_alert = { LESSON = reactive_advice_agent_scheme_rework }
				any_scheme = {
					any_scheme_agent_slot = {
						count > 0
					}
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_agent_scheme_rework
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_agent_scheme_rework
	}
}

action_reactive_advice_laamp_contract_move = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"

	check_create_action = {
		if = {
			limit = {
				has_ep3_dlc_trigger = yes
				government_has_flag = government_is_landless_adventurer
				is_travelling = no
				domicile ?= { provisions >= 250 }
				any_character_active_contract = { count < 1 }
				should_show_tutorial_alert = { LESSON = reactive_advice_laamp_contract_move }
				NOT = {
					should_show_tutorial_alert = { LESSON = reactive_advice_landless_adventurer }
				}
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_laamp_contract_move	
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_laamp_contract_move
	}
}

action_reactive_advice_migration = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"

	check_create_action = {
		if = {
			limit = {
				has_mpo_dlc_trigger = yes
				government_has_flag = government_is_nomadic
				is_travelling = no
				is_at_war = no
								
				OR = { 
					is_widgetid_open = window_migration
					current_domain_fertility < terrible_county_fertility_level
					months_from_game_start >= 20 

				}

				should_show_tutorial_alert = { LESSON = reactive_advice_migration }
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_migration	
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_migration
	}
}


action_reactive_advice_great_steppe = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"

	check_create_action = {
		if = {
			limit = {

				has_mpo_dlc_trigger = yes
				government_has_flag = government_is_nomadic

				should_show_tutorial_alert = { LESSON = reactive_advice_great_steppe }
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_great_steppe	
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_great_steppe
	}
}

action_reactive_advice_kurultai = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"

	check_create_action = {
		if = {
			limit = {
			
				has_mpo_dlc_trigger = yes
				government_has_flag = government_is_nomadic

				OR = { 
					months_from_game_start >= 24 
					has_chaotic_succession_trigger = yes
					is_widgetid_open = "my_realm_window"

				}
								
				should_show_tutorial_alert = { LESSON = reactive_advice_kurultai }
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_kurultai	
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_kurultai
	}
}

action_reactive_advice_tributaries = {
	type = tutorial
	icon = generic_reactive_advice
	soundeffect = "event:/SFX/UI/Notifications/TopBar/sfx_ui_notifications_topbar_reactive_advice"

	check_create_action = {
		if = {
			limit = {

				has_mpo_dlc_trigger = yes
				government_has_flag = government_is_nomadic

				OR = { 
					months_from_game_start >= 12 # Reactive Advice Queue
					is_widgetid_open = "my_realm_window"
					any_tributary = {
						count >= 1
					}
				}
								
				should_show_tutorial_alert = { LESSON = reactive_advice_tributaries }
			}
			try_create_important_action = {
				important_action_type = action_reactive_advice_tributaries	
				actor = root
			}
		}
	}

	effect = {
		start_tutorial_lesson = reactive_advice_tributaries
	}
}

