﻿# An artifact has changed ownership
# root = the artifact
# scope:owner = the person who now holds the artifact
# scope:old_owner = the person who used to hold the artifact
on_artifact_changed_owner = {
	events = {
		artifact.0011
		artifact.0101
	}

	effect = {
		save_scope_as = artifact
		grant_banner_house_claim_effect = yes
		every_artifact_claimant = { #This on_action is not triggered on succession for the ones getting the claim, so we force it here
			trigger_event = {
				on_action = on_artifact_claim_gained
			}
		}

		# Re-identify the Chad/Ironside skull whenever it changes hands.
		if = {
			limit = {
				has_variable = neow_chad_ironside_skull
			}
			neow_update_chad_ironside_skull_effect = yes
		}
	}
}

# An artifact has changed ownership due to succession
# This is called just before the artifact changes hands.
# If you destroy it or change its owner, it won't change hands
# on_artifact_changed_owner will be called as normal when it changes hands
# root = the artifact
# scope:owner = the person who now holds the artifact
# scope:old_owner = the person who used to hold the artifact
# scope:old_primary = the heir's primary before this succession happened
on_artifact_succession = {
	events = {
		artifact.0031
	}
}

# An artifact has reached 0 durability due to decay
# root = the artifact
# scope:owner = the person who owns the artifact
on_artifact_broken_through_decay = {
	events = {
		artifact.1000
	}
}

# An artifact has reached 0 durability due to an effect ( ex. damage )
# root = the artifact
# scope:owner = the person who owns the artifact
on_artifact_broken_through_effect = {
	events = {
		artifact.0021
	}
}

# Character gained a claim on an artifact
# root = character
# scope:owner = current artifact owner
# scope:artifact = claimed artifact
on_artifact_claim_gained = {
	effect = {
		send_interface_message = {
			type = msg_artifact_claim_gained
			title = artifact_claim_gained_notification
			right_icon = scope:artifact
			left_icon = scope:owner
			
			show_as_tooltip = {
				add_personal_artifact_claim = scope:artifact
			}
		}
	}
}

# Character lost a claim on an artifact
# root = character
# scope:owner = current artifact owner
# scope:artifact = artifact
on_artifact_claim_lost = {
	effect = {
		if = {
			limit = {
				scope:owner != root
			}
			send_interface_message = {
				type = msg_artifact_claim_lost
				title = artifact_claim_lost_notification
				right_icon = scope:artifact
				left_icon = scope:owner
				
				show_as_tooltip = {
					remove_personal_artifact_claim = scope:artifact
				}
			}
		}
	}
}

# Fired when an artifact reaches durability <= ARTIFACT_LOW_DURABILITY defıned in 00_defines.txt
# root = the artifact owner
on_artifact_durability_low = {
	random_events = {
		chance_to_happen = 50
		1000 = 0
		50 = artifact.3000
		50 = artifact.3010
		50 = artifact.3020
		50 = artifact.3030
		50 = artifact.3040
	}
}

# Fired when an artifact with hıgh quality reaches durability <= ARTIFACT_VERY_LOW_DURABILITY defıned in 00_defines.txt
# root = the artifact
# scope:owner = the person who owns the artifact
on_artifact_durability_very_low = {
	events = {
		artifact.3050
	}
}
