﻿###DUMMY COPY IDENTICAL TO VANILLA FOR TESTING###
###DELETE AFTER USE###

#On actions about titles

# A title is destroyed
# root = the holder before destruction
# scope:landed_title = the title that is being destroyed
on_title_destroyed = {
	events = {
	}
}

# A title is transferred to a new character
# root = the new holder
# scope:title = the title that changes hands
# scope:previous_holder = previous holder. Might be dead
on_title_gain = {
	effect = {
		if = {
			limit = {
				scope:title = { is_holy_order = yes }
				NOT = { has_trait = order_member }
				has_government = holy_order_government
			}
			add_trait = order_member
		}

		#Did I receive a title from my sibling?
		if = {
			limit = {
				exists = scope:previous_holder
				scope:previous_holder = {
					is_alive = yes
					exists = var:sibling_waiting_for_land
					any_sibling = {
						this = root
						this = scope:previous_holder.var:sibling_waiting_for_land
					}
				}
			}
			add_character_flag = {
				flag = got_title_from_sibling
				years = 4
			}
		}
		apply_limit_modifiers_effect = yes
	}
	events = {
		roman_restoration.0005 #New Roman Emperor gets Augustus trait. (old holder, if still alive, loses it)
		roman_restoration.0199 #Restoring the Pentarchy.
		religious_decision.0312 #New holder of a county with a runestone
		coa.1 # check if title Coat of Arms should change.
	}
}

# A title is inherited by a character
# root = the new holder
# scope:title = the title that changes hands
# scope:previous_holder = previous holder. Should be dead
on_title_gain_inheritance = {
	events = {
	}
	effect = {
		if = {
			limit = {
				scope:title = title:e_mongol_empire
				has_character_flag = gain_mongol_succession_dread
			}
			add_dread = 50
		}
		if = {
			limit = { 
				has_character_flag = shatter_empire
				#has_realm_law = confederate_partition_succession_law
				scope:title = { 
					tier = tier_empire 
				}
			}
			remove_character_flag = shatter_empire
			confed_partition_succ_shatter_effect = yes
		}
		#apply_limit_modifiers_effect = yes #In case it isn't caught by on_title_gain
	}
}

# A title is usurped by a character
# root = the new holder
# scope:title = the title that changes hands
# scope:previous_holder = previous holder. Shouldn't be dead
on_title_gain_usurpation = {
	events = {
	}
}

# 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 = {
	events = {
	}
}

# A claim is gained by a character
# root = the claimant
# scope:title = the title that is claimed
on_explicit_claim_gain = {
	events = {
		coa.1 # check if title Coat of Arms should change.
	}
}

# A claim is lost by a character
# root = the claimant
# scope:title = the title that was claimed
on_explicit_claim_lost = {
	events = {
		coa.1 # check if title Coat of Arms should change.
	}
}

# A title change makes the character rank up in the landed tiers (eg Duke -> King)
# root = character ranking up
# scope:title = old primary title
on_rank_up = { # Will not fire during history execution or for dying characters
	events = {
	}
	effect = {
		add_achievement_flag = { FLAG = achievement_moving_up_in_the_world_flag }
		update_embassies_effect = yes
		every_ally = {
			update_embassies_effect = yes
		}
	}
}

# A title change makes the character rank down in the landed tiers (eg King -> Duke)
# root = character ranking down
# scope:title = old primary title
on_rank_down = { # Will not fire during history execution or for dying characters
	events = {
	}
	effect = {
		add_character_flag = {
			flag = make_suicide_available
			years = 5
		}
		update_embassies_effect = yes
		every_ally = {
			update_embassies_effect = yes
		}
	}
}
