﻿# Ambitions - The Judgment - scripted effects (new in 1.4)
# Scope: character

# Add 1 to a counter variable, creating it at 1 if needed
amb_count_effect = {
	if = {
		limit = { has_variable = $VAR$ }
		change_variable = {
			name = $VAR$
			add = 1
		}
	}
	else = {
		set_variable = {
			name = $VAR$
			value = 1
		}
	}
}

# Run on death: the first verdict that fits gives a nickname and marks the heir
amb_judgment_effect = {
	if = {
		limit = { amb_verdict_legendary_trigger = yes }
		give_nickname = nick_amb_the_legendary
		amb_judgment_heir_effect = { VERDICT = legendary }
	}
	else_if = {
		limit = { amb_verdict_oathbreaker_trigger = yes }
		give_nickname = nick_amb_the_oathbreaker
		amb_judgment_heir_effect = { VERDICT = oathbreaker }
	}
	else_if = {
		limit = { amb_verdict_faithful_trigger = yes }
		give_nickname = nick_amb_the_faithful
		amb_judgment_heir_effect = { VERDICT = faithful }
	}
	else_if = {
		limit = { amb_verdict_dutiful_trigger = yes }
		give_nickname = nick_amb_the_dutiful
		amb_judgment_heir_effect = { VERDICT = dutiful }
	}
	else_if = {
		limit = { amb_verdict_fulfilled_trigger = yes }
		give_nickname = nick_amb_the_fulfilled
		amb_judgment_heir_effect = { VERDICT = fulfilled }
	}
	else_if = {
		limit = { amb_verdict_unfulfilled_trigger = yes }
		give_nickname = nick_amb_the_unfulfilled
		amb_judgment_heir_effect = { VERDICT = unfulfilled }
	}
}

amb_judgment_heir_effect = {
	if = {
		limit = { exists = primary_heir }
		primary_heir = {
			add_character_modifier = {
				modifier = amb_legacy_$VERDICT$_modifier
				years = 15
			}
			if = {
				limit = { is_ai = no }
				set_variable = {
					name = amb_verdict_seen
					value = flag:$VERDICT$
					days = 90
				}
				trigger_event = {
					id = amb.0009
					days = 7
				}
			}
		}
	}
}
