﻿# Ambitions - Vows - scripted effects (new in 1.3)
# Scope: character

# Swear a vow. TYPE = flag name, YEARS = length.
amb_vow_start_effect = {
	set_variable = {
		name = amb_vow_active
		value = flag:$TYPE$
	}
	set_variable = {
		name = amb_vow_timer
		value = 1
		years = $YEARS$
	}
	add_character_modifier = {
		modifier = amb_vow_keeping_modifier
		years = $YEARS$
	}
}

# Show the current vow as a tooltip (decision effect box)
amb_vow_show_effect = {
	if = {
		limit = { var:amb_vow_active = flag:peace }
		custom_tooltip = amb_vow_peace_tt
	}
	else_if = {
		limit = { var:amb_vow_active = flag:poverty }
		custom_tooltip = amb_vow_poverty_tt
	}
	else_if = {
		limit = { var:amb_vow_active = flag:vengeance }
		custom_tooltip = amb_vow_vengeance_tt
	}
	else_if = {
		limit = { var:amb_vow_active = flag:charity }
		custom_tooltip = amb_vow_charity_tt
	}
	else_if = {
		limit = { var:amb_vow_active = flag:chastity }
		custom_tooltip = amb_vow_chastity_tt
	}
}

# End the vow and block a new one for 3 years
amb_vow_clear_effect = {
	custom_tooltip = amb_vow_ends_tt
	custom_tooltip = amb_vow_rest_tt
	remove_variable = amb_vow_active
	remove_variable = amb_vow_timer
	remove_variable = amb_vow_breaking
	remove_character_modifier = amb_vow_keeping_modifier
	set_variable = {
		name = amb_vow_cooldown
		value = 1
		years = 3
	}
}

# Yearly check: broken first, then fulfilled, then the yearly alms
# (amb_vow_breaking means a broken-vow event is already on its way)
amb_vow_check_effect = {
	if = {
		limit = { NOT = { has_variable = amb_vow_breaking } }
		if = {
			limit = { amb_vow_broken_trigger = yes }
			set_variable = {
				name = amb_vow_breaking
				value = 1
				days = 60
			}
			trigger_event = amb_vow.0004
		}
		else_if = {
			limit = { amb_vow_vengeance_met_trigger = yes }
			trigger_event = amb_vow.0003
		}
		else_if = {
			limit = { NOT = { has_variable = amb_vow_timer } }
			if = {
				limit = { var:amb_vow_active = flag:vengeance }
				trigger_event = amb_vow.0004
			}
			else = {
				trigger_event = amb_vow.0003
			}
		}
		else_if = {
			limit = { var:amb_vow_active = flag:charity }
			trigger_event = amb_vow.0005
		}
	}
}

amb_vow_reward_effect = {
	if = {
		limit = { var:amb_vow_active = flag:vengeance }
		add_prestige = major_prestige_gain
	}
	else = {
		add_piety = major_piety_gain
	}
	add_stress = -25
	add_character_modifier = {
		modifier = amb_vow_kept_modifier
		years = 10
	}
	amb_count_effect = { VAR = amb_n_vows_kept }
}

amb_vow_break_effect = {
	add_stress = 40
	add_prestige = -150
	add_piety = -100
	add_character_modifier = {
		modifier = amb_oathbreaker_modifier
		years = 10
	}
	amb_count_effect = { VAR = amb_n_vows_broken }
}

# Renouncing openly is less shameful than breaking in secret
amb_vow_renounce_effect = {
	add_stress = 20
	add_prestige = -75
	add_piety = -50
	add_character_modifier = {
		modifier = amb_oathbreaker_modifier
		years = 5
	}
	amb_count_effect = { VAR = amb_n_vows_broken }
}
