﻿
### Events fired by Perk Interactions
namespace = perk_interaction


##################################################
# Someone has bought a claim on my title
# by Petter Vilberg
# 0001 - 0010
##################################################

#	Fired from the buy_claim_interaction
perk_interaction.0002 = {
	type = character_event
	title = perk_interaction.0002.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:actor.faith = scope:recipient.faith
				}
				desc = perk_interaction.0002.same_faith
			}
			desc = perk_interaction.0002.other_faith
		}
	}
	theme = vassal
	left_portrait = scope:actor
	
	option = {
		name = perk_interaction.0002.a
		show_as_tooltip = {
			scope:actor = {
				add_unpressed_claim = scope:target
			}
		}
	}
}

##################################################
# Rival Challenged to Bout
# by Ewan Cowhig Croft
# 0101 - 0120
##################################################
scripted_effect perk_interaction_0101_apply_effects_effect = {
	scope:sc_victor = { add_stress = major_stress_loss }
	scope:sc_loser = { add_stress = major_stress_gain }
}

#	Follow-up event.
perk_interaction.0101 = {
	hidden = yes

	immediate = {
		# Fire the follow-up stuff; delay this by a day so the toasts appear _after_ the final event.
		trigger_event = {
			id = perk_interaction.0103
			days = 1
		}
	}
}

#	Invalidation event.
perk_interaction.0102 = {
	hidden = yes

	immediate = {
		# Everyone puts their shirts back on.
		single_combat_clean_shirtlessness_effect = {
			ATTACKER = scope:actor
			DEFENDER = scope:recipient
		}
		# Inform both parties that the bout has invalidated.
		scope:actor = {
			send_interface_toast = {
				title = perk_interaction.0102.actor_toast.t
				left_icon = scope:actor
				right_icon = scope:recipient
				custom_tooltip = perk_interaction.0102.bout_invalidated.tt
			}
		}
		scope:recipient = {
			send_interface_toast = {
				title = perk_interaction.0102.recipient_toast.t
				left_icon = scope:recipient
				right_icon = scope:actor
				custom_tooltip = perk_interaction.0102.bout_invalidated.tt
			}
		}
	}
}

#	Delayed mechanical working-out event.
perk_interaction.0103 = {
	hidden = yes

	immediate = {
		# Everyone puts their shirts back on.
		single_combat_clean_shirtlessness_effect = {
			ATTACKER = scope:actor
			DEFENDER = scope:recipient
		}
		# Send out a toast to the victor.
		scope:sc_victor = {
			send_interface_toast = {
				title = perk_interaction.0101.victor_toast.t
				left_icon = scope:sc_victor
				right_icon = scope:sc_loser
				show_as_tooltip = { perk_interaction_0101_apply_effects_effect = yes }
			}
		}
		# And to the loser.
		scope:sc_loser = {
			send_interface_toast = {
				title = perk_interaction.0101.loser_toast.t
				left_icon = scope:sc_loser
				right_icon = scope:sc_victor
				show_as_tooltip = { perk_interaction_0101_apply_effects_effect = yes }
			}
		}
		# Then execute the actual effects.
		perk_interaction_0101_apply_effects_effect = yes
	}
}

##################################################
# Playing Chess
# by Ewan Cowhig Croft
# 0121 - 0140
##################################################

#	Follow-up event.
perk_interaction.0121 = {
	hidden = yes

	immediate = {
		# We don't bother with a delay here because there's no risk of death, and we want to transfer counties and such immediately.
		# Send out a toast to the victor.
		scope:bg_victor = {
			send_interface_toast = {
				title = perk_interaction.0122.victor_toast.t
				left_icon = scope:bg_victor
				right_icon = scope:bg_loser
				show_as_tooltip = { perk_interaction_0122_apply_effects_effect = yes }
			}
		}
		# And to the loser.
		scope:bg_loser = {
			send_interface_toast = {
				title = perk_interaction.0122.loser_toast.t
				left_icon = scope:bg_loser
				right_icon = scope:bg_victor
				show_as_tooltip = { perk_interaction_0122_apply_effects_effect = yes }
			}
		}
		# Then execute the actual effects.
		perk_interaction_0122_apply_effects_effect = yes
	}
}
