﻿# A title is lost by a character
# root = the old holder
# scope:title = the title that changes hands
# scope:new_holder = new holder.
on_title_lost = {
	on_actions = { on_title_lost_lwxxx }
}

on_title_lost_lwxxx = {
	trigger = {
		root = {
			has_variable = lwxxx_had_last_will_succession_law
			scope:title = { lwxxx_title_has_last_will_claimant_trigger = yes }
		}
	}

	effect = {
		if = {
			limit = {
				scope:title = { lwxxx_title_has_last_will_claimant_trigger = yes }
			}

			scope:title = { lwxxx_remove_last_will_claimant_effect = yes }
		}
	}
}

on_death = {
	on_actions = { lwxxx_on_Death }
}

lwxxx_on_Death = {
	trigger = {
		root = {
			has_variable = lwxxx_had_last_will_succession_law
		}
	}

	effect = {
		every_held_title = {
			limit = {
				has_variable = lwxxx_title_abdicator
			}

			remove_variable = lwxxx_title_abdicator
		}

		hidden_effect = {
			depose = yes
		}
	}
}
