﻿loaa_artifact_acceptance_trigger = {
	$ARTIFACT$ = { save_temporary_scope_as = artifact }
	$CONTRACT_EMPLOYER$ = { save_temporary_scope_as = employer }
	$CONTRACT_TARGET$ = { save_temporary_scope_as = contract_target }
	save_temporary_scope_value_as = {
		name = acceptance
		value = {
			value = 0
			add = 100
			if = {
				limit = {
					NOT = {
						scope:contract_target = {
							can_equip_artifact = scope:artifact
						}
					}
				}
				add = -80
			}
			if = {
				limit = {
					NOT = {
						scope:contract_target= {
							can_benefit_from_artifact = scope:artifact
						}
					}
				}
				add = -40
			}
			if = {
				limit = {
					scope:artifact = {
						has_variable = unwanted_artifact
					}
				}
				add = -500
			}
			if = {
				limit = {
					scope:artifact = {
						has_variable = cursed_artifact
					}
				}
				add = -1000
			}
			if = {
				limit = {
					exists = scope:artifact.var:banner_dynasty
					exists = scope:contract_target.dynasty
					scope:contract_target = scope:artifact.var:banner_dynasty.dynast
				}
				add = 100
			}
			if = {
				limit = {
					OR = {
						exists = scope:artifact.var:banner_dynasty
						exists = scope:artifact.var:banner_house
					}
					exists = scope:contract_target.house
					trigger_if = {
						limit = { exists = scope:artifact.var:banner_dynasty }
						NOT = { scope:artifact.var:banner_dynasty = scope:contract_target.dynasty }
					}
					trigger_else = {
						NOT = { scope:artifact.var:banner_house = scope:contract_target.house }
					}
				}
					add = -200
			}
			if = {
				limit = {
					scope:contract_target = {
						is_independent_ruler = yes
						any_character_struggle = {
							involvement = involved
						}
					}
				}
				add = {
					value = 0
					if = {
						limit = {
							scope:contract_target = {
								any_character_struggle = {
									phase_has_catalyst = catalyst_gift_independent_ruler
								}
								has_character_flag = agenda_towards_escalation
							}
						}
						add = -100
					}
					else_if = {
						limit = {
							scope:contract_target = {
								any_character_struggle = {
									phase_has_catalyst = catalyst_gift_independent_ruler
								}
							}
						}
						add = 200
					}
				}
			}
			# Struggle motive
			if = {
				limit = {
					scope:contract_target = {
						is_independent_ruler = yes
						any_character_struggle = {
							involvement = involved
						}
					}
				}
				add = {
					value = 0
					if = {
						limit = {
							scope:contract_target = {
								any_character_struggle = {
									phase_has_catalyst = catalyst_gift_independent_ruler
								}
								has_character_flag = agenda_towards_escalation
							}
						}
						add = -100
					}
					else_if = {
						limit = {
							scope:contract_target = {
								any_character_struggle = {
									phase_has_catalyst = catalyst_gift_independent_ruler
								}
							}
						}
						add = 200
					}
				}
			}

			# # House Unity
			if = {
				limit = {
					scope:employer = {
						government_has_flag = government_is_clan
						house ?= scope:contract_target.house
					}
				}
				add = {
					value = 100
					scope:contract_target = {
						### Personality
						# Warmonger and Ambitious AI wants a low unity to expand while peaceful and economy focused wants Harmonious
						if = {
							limit = { ai_wants_high_unity = yes }
							multiply = 1.2
						}
						else_if = {
							limit = { ai_wants_low_unity = yes }
							multiply = 0.8
						}

						### House Head related
						# Do I want to  be rescued if outside of the realm
						if = {
							limit = {
								# if you are under impassive, you really want to increase unity
								house ?= {
									OR = {
										has_house_unity_stage = antagonistic
										has_house_unity_stage = competitive
										has_house_unity_stage = impassive

									}
								}
								# only valid for people outside of their liege realm
								NOR ={
									house.house_head = top_liege
									house.house_head = liege
								}

							}
							multiply = 1.2
						}

						### Struggle
						if = {
							limit = { has_trait = fp3_struggle_supporter }
							multiply = 1.5
						}
						else_if = {
							limit = { has_trait = fp3_struggle_detractor }
							multiply = 0.5
						}

						### Current Unity state
						# lower the overall weight if unity is already high: you don't care of increasing unity if you are at 100
						if = {
							limit = {
								house ?= {
									has_house_unity_stage = antagonistic
								}
							}
							multiply = 1.2
						}
						else_if = {
							limit = {
								house ?= {
									has_house_unity_stage = competitive
								}
							}
							multiply = 1.1
						}
						else_if = {
							limit = {
								house ?= {
									has_house_unity_stage = friendly
								}
							}
							multiply = 0.9
						}
						else_if = {
							limit = {
								house ?= {
									has_house_unity_stage = harmonious
								}
							}
							multiply = {
								value = {
									add = 0.8
									if = {
										limit = {
											house ?= { house_unity_value >= very_high_house_unity }
										}
										multiply = 0.5
									}
								}
							}
						}
					}
				}
			}
		}
	}

	scope:acceptance > 0
}