# On actions for knight events, triggered automatically by the game

# Called for commanders when combat ends
# root is the commander
# scope:combat_side is the side of combat the commander is on
# scope:victory is whether the commander's side won

on_commander_combat_finished = {
	trigger = {
		scope:victory = no
	}

	events = {
		# DISABLED as how this is handled is undergoing a rework.
		#commanders.0011 # Commander captured after combat.
	}
}

# called on every unique owner of an army on combat end
# root is the owning character
# scope:combat_side is the side of combat the commander is on
# scope:victory is whether the commander's side won
# commanders is a list of all commanders in the combat
# knights is a list of all knights in the combat
on_army_combat_finished = {
	
}

# Used for handling the Varangian guard
varangian_ongoing = {
	trigger = {
		has_character_flag = is_currently_varangian
	}
	effect = {

		#Verify if the character became landed: in that case, remove the flag
		if = {
			limit = {
				is_ruler = yes
			}
			remove_character_flag = is_currently_varangian
		}
		else = {
			#debug_log = "Fired the varangian_ongoing pulse"
			#debug_log_scopes = yes
			change_variable = { # NOTE: Will *not* be relevant to non-delayed trigger evaluations for the events below
				name = years_as_varangian
				add = 1
			}
			trigger_event = {
				on_action = varangian_ongoing
				days = { 340 380 }
			}
		}
	}
	random_events = {
		500 = 0
#		500 = varangian.1001 # Return home
#		100 = varangian.2001 # Become Best Friends with another Varangian
#		100 = varangian.2002 # Become Lover with another Varangian
#		100 = varangian.2003 # Become Friends with a local ruler
#		100 = varangian.2004 # Become Rival with a local ruler
#		300 = varangian.2005 # Marry Lover
#		100 = varangian.2008 # Get wounded
#		100 = varangian.2011 # Get local Lover
#		200 = varangian.2012 # Increase Prowess
#		200 = varangian.2013 # Increase Martial
#		200 = varangian.2014 # Increase Learning
#		200 = varangian.2015 # Increase Diplomacy
#		50 = varangian.2016 # Become Brave
#		50 = varangian.2017 # Become Ambitious
#		50 = varangian.2018 # Become Diligent
	}
}
