﻿upgrade_agot_artifact_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_smith.dds"
	
#	cooldown = { days = standard_commission_artifact_cooldown_time }
	sort_order = 100
	
	is_shown = {
		is_landed = yes
		highest_held_title_tier >= tier_county
		exists = capital_province
		any_character_artifact {
			exists = this
		}
	}
	
	is_valid = {
		custom_description = {
			text = ant_req
			court_position:antiquarian_court_position = {
				aptitude:antiquarian_court_position >= 4
			}
		}
		custom_description = {
			text = reforge_requirement_armor
			any_character_artifact = {
				AND = {
					artifact_has_room_for_improvement = yes
					NOT = {  rarity = illustrious }
				}
			}
		}
	}
	
	is_valid_showing_failures_only = {
		# Only valid for characters with an antiquarian.
		employs_court_position = antiquarian_court_position
	}

	minimum_cost = {
		# Matches the cost defined in 00_inspirations.txt
		#gold = basic_fund_inspiration_cost
	}
	
	widget = {
    	gui = "decision_view_widget_upgrade_artifact"
		controller = decision_option_list_controller
		
		decision_has_second_step = yes
		decision_custom_widget_container = "custom_widgets_container_step_two"
		decision_to_second_step_button = "AGOT_UPGRADE_ARTIFACT_DECISION_NEXT_STEP_BUTTON" 


		# Personal Artifacts are always valid to commission		
		item = {
			value = commission_valyrian_weapon
			is_shown = {
				any_artifact = {
					has_variable = valyrian_steel
				}
			}
			is_valid = {
				any_character_artifact = {
					has_variable = valyrian_steel
					has_variable = can_upgrade
				}
			}			
			current_description = {
				desc = commission_artifact_decision_option_weapon_desc
			}
			localization  = {				
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								any_character_artifact = {
									AND = {
										artifact_slot_type = primary_armament
										has_variable = valyrian_steel
									}
								}
							}
							desc = agot_uprade_artifact_decision_option_valyrian_weapon
						}						
						desc = agot_uprade_artifact_decision_option_valyrian_weapon_2
					}
				}				
				
			}
			icon = "gfx/interface/icons/artifact/vs_pride.dds"

			ai_chance = {
				value = 0 
				if = {
					limit = {
						OR = {
							has_trait = greedy
						}
					}
					add = 0
				}
			}
		}
		
		item = {
			value = commission_weapon
			is_valid = {
				any_character_artifact = {
					AND = {
						artifact_slot_type = primary_armament
						NOT = { has_variable = valyrian_steel } 
						artifact_has_room_for_improvement = yes
						NOT = {  rarity = illustrious }
					}
				}
			}			
			current_description = {
				desc = commission_artifact_decision_option_weapon_desc
			}
			localization  = {				
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								any_character_artifact = {
									AND = {
										artifact_slot_type = primary_armament
										NOT = { has_variable = valyrian_steel } 
										NOT = {  rarity = illustrious }
									}
								}
							}
							desc = agot_uprade_artifact_decision_option_weapon
						}
						triggered_desc = {
							trigger = {
								AND = {									
									NOT = {
										any_character_artifact = {
											artifact_slot_type = primary_armament
											NOT = { has_variable = valyrian_steel } 
										}
									}
								}
							}
							desc = agot_uprade_artifact_decision_option_weapon_1
						}							
						desc = agot_uprade_artifact_decision_option_weapon_2
					}
				}				
				
			}
			icon = "gfx/interface/icons/artifact/artifact_sword.dds"

			ai_chance = {
				value = 0 
			}
		}

		item = {
			value = commission_armor
			is_valid = {
				any_character_artifact = {
					AND = {
						artifact_has_room_for_improvement = yes
						NOT = {  rarity = illustrious }
						artifact_slot_type = armor
					}
				}
			}		
			current_description = {
				desc = commission_artifact_decision_option_armor_desc
			}
			localization  = {				
				desc = {
					first_valid = {						
						triggered_desc = {
							trigger = {
								any_character_artifact = {
									AND = {
										artifact_slot_type = armor
										NOT = {  rarity = illustrious }
									}									
								}
							}
							desc = agot_uprade_artifact_decision_option_armor
						}	
						triggered_desc = {
							trigger = {
								AND = {									
									NOT = {
										any_character_artifact = {
											artifact_slot_type = armor
										}
									}
								}
							}
							desc = agot_uprade_artifact_decision_option_armor_1
						}						
						desc = agot_uprade_artifact_decision_option_armor_2
					}
				}				
				
			}
			
				
			icon = "gfx/interface/icons/artifact/artifact_armor.dds"

			ai_chance = {
				value = 0 
				
			}
		}

		item = {
			value = commission_crown
			is_valid = {
				any_character_artifact = {
					AND = {
						artifact_has_room_for_improvement = yes
						NOT = {  rarity = illustrious }
						artifact_slot_type = helmet
					}
				}
			}
			current_description = {
				desc = commission_artifact_decision_option_crown_desc
			}
			localization  = {				
				desc = {
					first_valid = {						
						triggered_desc = {
							trigger = {
								any_character_artifact = {
									AND = {
										artifact_slot_type = helmet
										NOT = {  rarity = illustrious }
									}									
								}
							}
							desc = agot_uprade_artifact_decision_option_crown
						}	
						triggered_desc = {
							trigger = {
								AND = {									
									NOT = {
										any_character_artifact = {
											artifact_slot_type = helmet
										}
									}
								}
							}
							desc = agot_uprade_artifact_decision_option_crown_1
						}	
						desc = agot_uprade_artifact_decision_option_crown_2
					}
				}				
				
			}
			icon = "gfx/interface/icons/artifact/artifact_crown.dds"

			ai_chance = {
				value = 0 
				
			}
		}

		item = {
			value = commission_regalia
			is_valid = {
				any_character_artifact = {
					AND = {
						artifact_has_room_for_improvement = yes
						NOT = {  rarity = illustrious }
						artifact_slot_type = regalia
					}
				}
			}
			current_description = {
				desc = commission_artifact_decision_option_regalia_desc
			}
			localization  = {				
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								any_character_artifact = {
									AND = {
										artifact_slot_type = regalia
										NOT = {  rarity = illustrious }
									}									
								}
							}
							desc = agot_uprade_artifact_decision_option_regalia
						}	
						triggered_desc = {
							trigger = {
								AND = {									
									NOT = {
										any_character_artifact = {
											artifact_slot_type = regalia
										}
									}
								}
							}
							desc = agot_uprade_artifact_decision_option_regalia_1
						}	
						desc = agot_uprade_artifact_decision_option_regalia_2
					}
				}				
				
			}
			icon = "gfx/interface/icons/artifact/artifact_regalia.dds"

			ai_chance = {
				value = 0 
				
			}
		}

		# Court Artifacts only appear if you have the Royal Court DLC, and are only valid if you have an active Royal Court
		
		item = {
			value = commission_tapestry
			is_shown = { has_dlc_feature = royal_court }
			is_valid = { 
				OR = {
					any_character_artifact = {
						artifact_has_room_for_improvement = yes
						NOT = {  rarity = illustrious }
						artifact_slot_type = wall_big
					}
					any_character_artifact = {
						artifact_has_room_for_improvement = yes
						NOT = {  rarity = illustrious }
						artifact_slot_type = wall_small
					}
				}
			}
			current_description = {
				desc = commission_artifact_decision_option_tapestry_desc
			}
			localization  = {				
				desc = {
					first_valid = {						
						triggered_desc = {
							trigger = {
								any_character_artifact = {
									AND = {
										OR = {
											artifact_slot_type = wall_big
											artifact_slot_type = wall_small
										}	
										NOT = {  rarity = illustrious }
									}									
								}
							}
							desc = agot_uprade_artifact_decision_option_tapestry
						}	
						triggered_desc = {
							trigger = {
								AND = {									
									NOT = {
										any_character_artifact = {
											OR = {
												artifact_slot_type = wall_big
												artifact_slot_type = wall_small
											}
										}
									}
								}
							}
							desc = agot_uprade_artifact_decision_option_tapestry_1
						}	
						desc = agot_uprade_artifact_decision_option_tapestry_2
					}
				}				
				
			}
			icon = "gfx/interface/icons/artifact/artifact_tapestry.dds"

			ai_chance = {
				value = 0 
				
			}
		}

		item = {
			value = commission_furniture
			is_shown = { has_dlc_feature = royal_court  }
			is_valid = { 
				any_character_artifact = {
					artifact_has_room_for_improvement = yes
					NOT = {  rarity = illustrious }
					OR = {
						artifact_slot_type = sculpture
						artifact_slot_type = pedestal
						artifact_slot_type = throne
					}
				}
			}
			current_description = {
				desc = commission_artifact_decision_option_furniture_desc
			}
			localization  = {				
				desc = {
					first_valid = {						
						triggered_desc = {
							trigger = {
								any_character_artifact = {
									AND = {
										OR = {
											artifact_slot_type = sculpture
											artifact_slot_type = pedestal
											artifact_slot_type = throne
										}
										NOT = {  rarity = illustrious }
									}									
								}
							}
							desc = agot_uprade_artifact_decision_option_furniture
						}	
						triggered_desc = {
							trigger = {
								AND = {									
									NOT = {
										any_character_artifact = {
											OR = {
												artifact_slot_type = sculpture
												artifact_slot_type = pedestal
												artifact_slot_type = throne
											}
										}
									}
								}
							}
							desc = agot_uprade_artifact_decision_option_furniture_1
						}
						desc = agot_uprade_artifact_decision_option_furniture_2
					}
				}				
				
			}
			icon = "gfx/interface/icons/artifact/artifact_cabinet.dds"

			ai_chance = {
				value = 0 
				
			}
		}

		item = {
			value = commission_book
			is_shown = { has_dlc_feature = royal_court  }
			is_valid = { 
				any_character_artifact = {
					artifact_has_room_for_improvement = yes
					NOT = {  rarity = illustrious }
					artifact_slot_type = book
				}
			}
			current_description = {
				desc = commission_artifact_decision_option_book_desc
			}
			localization  = {				
				desc = {
					first_valid = {						
						triggered_desc = {
							trigger = {
								any_character_artifact = {
									AND = {
										artifact_slot_type = book
										NOT = {  rarity = illustrious }
									}									
								}
							}
							desc = agot_uprade_artifact_decision_option_book
						}	
						triggered_desc = {
							trigger = {
								AND = {									
									NOT = {
										any_character_artifact = {
											artifact_slot_type = book
										}
									}
								}
							}
							desc = agot_uprade_artifact_decision_option_book_1
						}
						desc = agot_uprade_artifact_decision_option_book_2
					}
				}				
				
			}
			icon = "gfx/interface/icons/artifact/artifact_book.dds"

			ai_chance = {
				value = 0 
				if = {
					limit = {
						# Only make this choice if we don't already have an artifact of this type.
						NOT = {
							any_character_artifact = {
								artifact_slot_type = book
							}
						}
					}
					add = 100
				}
			}
		}

		#Alchemy isn't included here since that inspiration is much more tied to the pursuit of knowledge initiated by the inspired person
	}

	effect = {
	
		
		# Explanatory Tooltips
		custom_tooltip = reforge_artifact_decision_effect
		

		
		

		hidden_effect = {
					if = {
						limit = { scope:commission_weapon = yes }
						trigger_event = reforge_artifact_val.1000
					}
					else_if = {
						limit = { scope:commission_armor = yes }
						trigger_event = reforge_artifact_val.1000
					}
					else_if = {
						limit = { scope:commission_crown = yes }
						trigger_event = reforge_artifact_val.1000
					}
					else_if = {
						limit = { scope:commission_regalia = yes }
						trigger_event = reforge_artifact_val.1000
					}
					else_if = {
						limit = { scope:commission_tapestry = yes }
						trigger_event = reforge_artifact_val.1000
					}
					else_if = {
						limit = { scope:commission_furniture = yes }
						trigger_event = reforge_artifact_val.1000
					}
					else_if = {
						limit = { scope:commission_book = yes }
						trigger_event = reforge_artifact_val.1000
					}
		}
	}

	ai_check_interval = 36
	
	ai_potential = {
		is_at_war = no
		ai_greed < medium_positive_ai_value
		short_term_gold > ai_war_chest_desired_gold_value
		war_chest_gold >= halved_ai_war_chest_gold_maximum
	}

	ai_will_do = {
		base = 100

		modifier = {
			factor = 0
			has_royal_court = yes
			any_character_artifact = {
				artifact_slot_type = primary_armament
			}
			any_character_artifact = {
				artifact_slot_type = armor
			}
			any_character_artifact = {
				artifact_slot_type = helmet
			}
			any_character_artifact = {
				artifact_slot_type = regalia
			}
			OR = {
				any_character_artifact = {
					artifact_slot_type = wall_big
				}
				any_character_artifact = {
					artifact_slot_type = wall_small
				}
			}
			any_character_artifact = {
				artifact_slot_type = sculpture
			}
			any_character_artifact = {
				artifact_slot_type = book
			}
		}

		modifier = {
			factor = 0
			has_royal_court = no
			any_character_artifact = {
				artifact_slot_type = primary_armament
			}
			any_character_artifact = {
				artifact_slot_type = armor
			}
			any_character_artifact = {
				artifact_slot_type = helmet
			}
			any_character_artifact = {
				artifact_slot_type = regalia
			}
		}
	}
}