﻿holy_stuff_artifact_purchase_scripted_effect = {
      
		scope:target = {
			set_variable = suppress_artifact_notifications
			set_variable = { name = sold_artifact value = yes days = 9125 }
		}
		scope:recipient = {
			if = {
			scope:recipient = {
					if = {
						limit = {
							exists = scope:target
						}
						pay_short_term_gold = {
							target = scope:actor
							gold = sell_artifact_cost
						}
					}
				}
			}
		}
		scope:actor = {
			send_interface_toast = {
				type = event_generic_neutral
				title = bought_artifact_interaction_notification
				left_icon = scope:recipient
				right_icon = scope:target
				scope:recipient = {
					if = {
						limit = {
							scope:target = { can_be_claimed_by = scope:recipient }
						}
						if = {
							limit = {
								any_personal_claimed_artifact = { this = scope:target }
							}
							show_as_tooltip = { remove_personal_artifact_claim = scope:target }
						}
						else = {
							show_as_tooltip = { remove_house_artifact_claim = scope:target }
						}
					}
				}
				scope:target = {
					set_owner = scope:recipient
				}
			}

			if = {
				limit = {
					scope:target = { artifact_durability <= define:NInventory|ARTIFACT_LOW_DURABILITY }
				}
				custom_tooltip = artifact_purchase_low_durability_tt
			}
			if = {
				limit = {
					scope:target = { artifact_durability <= define:NInventory|ARTIFACT_VERY_LOW_DURABILITY }
				}
				custom_tooltip = artifact_purchase_very_low_durability_tt
			}
			if = {
				limit = {
					scope:target = { 
						OR = {
							AND = {
								has_variable = banner_house
								NOT = { var:banner_house = scope:recipient.house }
							}
							AND = {
								has_variable = banner_dynasty
								NOT = { var:banner_dynasty = scope:recipient.dynasty }
							}
						}
					}
				}
				custom_tooltip = artifact_purchase_useless_banner_tt
			}
			else_if = {
				limit = {
					scope:recipient = {
						NOR = {
							can_equip_artifact = scope:target
							can_benefit_from_artifact = scope:target
						}
					}
				}
				custom_tooltip = artifact_purchase_useless_tt
			}
			else_if = {
				limit = {
					scope:recipient = {
						NOT = { can_equip_artifact = scope:target }
					}
				}
				custom_tooltip = artifact_purchase_equip_tt
			}
			else_if = {
				limit = {
					scope:recipient = {
						NOT = { can_benefit_from_artifact = scope:target }
					}
				}
				custom_tooltip = artifact_purchase_benefit_tt
			}
			if = {
				limit = { scope:recipient.liege = scope:actor }
				custom_tooltip = artifact_purchase_vassal_tt
			}
			if = {
				limit = { scope:recipient = scope:actor.faith.religious_head }
				custom_tooltip = artifact_purchase_religious_head_tt
			}
		}
		scope:recipient = {
			hidden_effect = {
				send_interface_toast = {
					type = event_generic_neutral
				        title = sold_artifact_interaction_notification
					left_icon = scope:actor
					right_icon = scope:target
				scope:recipient = {
					if = {
						limit = {
							scope:target = { can_be_claimed_by = scope:recipient }
						}
						if = {
							limit = {
								any_personal_claimed_artifact = { this = scope:target }
							}
							show_as_tooltip = { remove_personal_artifact_claim = scope:target }
						}
						else = {
							show_as_tooltip = { remove_house_artifact_claim = scope:target }
						}
					}
				}
				scope:target = {
					set_owner = scope:recipient
				}
				if = {
					limit = {
						is_ruler = no
						trigger_if = {
							limit = {
								scope:target = {
									artifact_slot_type = primary_armament
								}
							}
							OR = {
								NOT = {
									any_equipped_character_artifact = {
										artifact_slot_type = primary_armament
									}
								}
								AND = {
									scope:target = {
										rarity = illustrious
									}
									any_equipped_character_artifact = {
										artifact_slot_type = primary_armament
										NOT = {
											rarity = illustrious
										}
									}
								}
								AND = {
									scope:target = {
										rarity = famed
									}
									any_equipped_character_artifact = {
										artifact_slot_type = primary_armament
										NOR = {
											rarity = illustrious
											rarity = famed
										}
									}
								}
								AND = {
									scope:target = {
										rarity = masterwork
									}
									any_equipped_character_artifact = {
										artifact_slot_type = primary_armament
										NOR = {
											rarity = illustrious
											rarity = famed
											rarity = masterwork
										}
									}
								}
								AND = {
									scope:target = {
										rarity = common
									}
									any_equipped_character_artifact = {
										artifact_slot_type = primary_armament
										NOR = {
											rarity = illustrious
											rarity = famed
											rarity = masterwork
											rarity = common
										}
									}
								}
							}
						}
						trigger_if = {
							limit = {
								scope:target = {
									artifact_slot_type = armor
								}
							}
							OR = {
								NOT = {
									any_equipped_character_artifact = {
										artifact_slot_type = armor
									}
								}
								AND = {
									scope:target = {
										rarity = illustrious
									}
									any_equipped_character_artifact = {
										artifact_slot_type = armor
										NOT = {
											rarity = illustrious
										}
									}
								}
								AND = {
									scope:target = {
										rarity = famed
									}
									any_equipped_character_artifact = {
										artifact_slot_type = armor
										NOR = {
											rarity = illustrious
											rarity = famed
										}
									}
								}
								AND = {
									scope:target = {
										rarity = masterwork
									}
									any_equipped_character_artifact = {
										artifact_slot_type = armor
										NOR = {
											rarity = illustrious
											rarity = famed
											rarity = masterwork
										}
									}
								}
								AND = {
									scope:target = {
										rarity = common
									}
									any_equipped_character_artifact = {
										artifact_slot_type = armor
										NOR = {
											rarity = illustrious
											rarity = famed
											rarity = masterwork
											rarity = common
										}
									}
								}
							}
						}
						trigger_if = {
							limit = {
								scope:target = {
									artifact_slot_type = regalia
								}
							}
							OR = {
								NOT = {
									any_equipped_character_artifact = {
										artifact_slot_type = regalia
									}
								}
								AND = {
									scope:target = {
										rarity = illustrious
									}
									any_equipped_character_artifact = {
										artifact_slot_type = regalia
										NOT = {
											rarity = illustrious
										}
									}
								}
								AND = {
									scope:target = {
										rarity = famed
									}
									any_equipped_character_artifact = {
										artifact_slot_type = regalia
										NOR = {
											rarity = illustrious
											rarity = famed
										}
									}
								}
								AND = {
									scope:target = {
										rarity = masterwork
									}
									any_equipped_character_artifact = {
										artifact_slot_type = regalia
										NOR = {
											rarity = illustrious
											rarity = famed
											rarity = masterwork
										}
									}
								}
								AND = {
									scope:target = {
										rarity = common
									}
									any_equipped_character_artifact = {
										artifact_slot_type = regalia
										NOR = {
											rarity = illustrious
											rarity = famed
											rarity = masterwork
											rarity = common
										}
									}
								}
							}
						}
						trigger_if = {
							limit = {
								scope:target = {
									artifact_slot_type = helmet
								}
							}
							OR = {
								NOT = {
									any_equipped_character_artifact = {
										artifact_slot_type = helmet
									}
								}
								AND = {
									scope:target = {
										rarity = illustrious
									}
									any_equipped_character_artifact = {
										artifact_slot_type = helmet
										NOT = {
											rarity = illustrious
										}
									}
								}
								AND = {
									scope:target = {
										rarity = famed
									}
									any_equipped_character_artifact = {
										artifact_slot_type = helmet
										NOR = {
											rarity = illustrious
											rarity = famed
										}
									}
								}
								AND = {
									scope:target = {
										rarity = masterwork
									}
									any_equipped_character_artifact = {
										artifact_slot_type = helmet
										NOR = {
											rarity = illustrious
											rarity = famed
											rarity = masterwork
										}
									}
								}
								AND = {
									scope:target = {
										rarity = common
									}
									any_equipped_character_artifact = {
										artifact_slot_type = helmet
										NOR = {
											rarity = illustrious
											rarity = famed
											rarity = masterwork
											rarity = common
										}
									}
								}
							}
						}
					}
					scope:target = {
						equip_artifact_to_owner_replace = yes
					}
				}
			}
		}

		}
}