decisions = { #General

	market_leave_store = {
		is_high_prio = yes
		ai_check_interval = 12000
		only_playable = yes
		
		potential = {
			is_in_marketplace_shop = yes
		}
		allow = {
		}
		effect = {
			market_leave_store_effect = yes
		}
	}

	ev_visit_library = {
		ai_check_interval = 12
		only_playable = yes
		
		potential = {
			OR = {
				has_character_flag = marketplace_open
				ai = yes
			}
			NOT = {
				has_character_flag = evlibraryvisiting
			}
		}
		allow = {
			prisoner = no
			wealth = 100
		}
		effect = {
			character_event = { id = ekevmisc.6 }
		}
		ai_will_do = {
			factor = 0.25
		}
	}

	purchase_mount = {
		only_playable = yes
		
		ai_check_interval = 3
		
		potential = {
			is_playable = yes
			OR = {
				has_character_flag = marketplace_open
				ai = yes
			}
			OR = {
				ai = no
				NOT = {
					any_artifact = {
						has_artifact_flag = mount
					}
				}
			}
			NOR = {
				has_character_flag = buying_a_pet
				trait = undead
			}
		}
		allow = {
			wealth = 100
			is_inaccessible_trigger = no
			prisoner = no
			NOT = { trait = incapable }
		}
		effect = {
			set_character_flag = buying_a_pet
			character_event = { id = ekpets.100 }
		}

		ai_will_do = {
			factor = 0.5
			modifier = {
				factor = 2.5
				wealth = 100
			}
			modifier = {
				factor = 5
				wealth = 200
			}
		}
	}
	
	purchase_pet = {
		only_playable = yes
		
		ai_check_interval = 36
		
		potential = {
			is_playable = yes
			OR = {
				has_character_flag = marketplace_open
				ai = yes
			}
			OR = {
				ai = no
				NOT = {
					any_artifact = {
						has_artifact_flag = pet
					}
				}
			}
			NOR = {
				has_character_flag = buying_a_pet
				trait = undead
			}
		}
		allow = {
			wealth = 50
			is_inaccessible_trigger = no
			prisoner = no
			NOT = { trait = incapable }
		}
		effect = {
			set_character_flag = buying_a_pet
			character_event = { id = ekpets.110 }
		}

		ai_will_do = {
			factor = 0.5
			modifier = {
				factor = 2.5
				wealth = 50
			}
			modifier = {
				factor = 5
				wealth = 100
			}
		}
	}
	
	ev_visit_blacksmith = { #haha not done yet
		ai_check_interval = 12
		only_playable = yes
		
		potential = {
			has_character_flag = evtestsmithing
			OR = {
				has_character_flag = marketplace_open
				ai = yes
			}
			NOT = {
				has_character_flag = evblacksmithvisiting
			}
		}
		allow = {
			prisoner = no
		}
		effect = {
			clr_character_flag = marketplace_open
			set_character_flag = evblacksmithvisiting
		}
		ai_will_do = { #TODO: Modifiers making them very likely to take this decision if they don't have an armor artifact or a weapon artifact.
			factor = 0.25
		}
	}
	
}

decisions = { #Alchemy - Giving it its own block for nesting purposes. When adding new potions, make sure you modify the trigger that checks for potions in character_triggers.txt.
	alch_ai_basic = { #Decision that allows the AI rudimentary access to alchemy
		ai_check_interval = 24
		only_playable = yes
		
		potential = {
			ai = yes
			is_adult = yes
			NOT = {
				chugged_it_down_innit_bruv = yes
			}
		}
		allow = {
			prisoner = no
			OR = {
				wealth = 100
				AND = {
					has_in_house_alchemy = yes
					wealth = 50
				}
			}
		}
		effect = {
			if = {
				limit = {
					has_in_house_alchemy = yes
				}
				wealth = -50
			}
			else = {
				wealth = -100
			}
			random_list = { #TODO: Weights based on current situation
				10 = { add_character_modifier = { name = modifier_potion_of_chameleon years = 5 } }
				10 = { add_character_modifier = { name = modifier_potion_of_fortify_health years = 5 } }
				10 = { add_character_modifier = { name = modifier_potion_of_virility years = 5 } }
				10 = { add_character_modifier = { name = modifier_potion_of_fortify_strength years = 5 } }
				10 = { add_character_modifier = { name = modifier_potion_of_fortify_personality years = 5 } }
				10 = { add_character_modifier = { name = modifier_potion_of_fortify_luck years = 5 } }
				10 = { add_character_modifier = { name = modifier_potion_of_fortify_intelligence years = 5 } }
				10 = { add_character_modifier = { name = modifier_potion_of_fortify_agility years = 5 } }
			}
		}
		ai_will_do = {
			factor = 0.5
			modifier = {
				factor = 1.25
				wealth = 300
			}
			modifier = {
				factor = 1.75
				wealth = 600
			}
			modifier = {
				factor = 1.25
				has_in_house_alchemy = yes
			}
		}
	}

	alch_potion_of_chameleon = {
		ai_check_interval = 12000
		only_playable = yes
		ai = no
		
		potential = {
			OR = {
				has_character_flag = alchemist_open
				#ai = yes
			}
			NOT = { has_character_modifier = modifier_potion_of_chameleon }
		}
		allow = {
			prisoner = no
			NOT = { chugged_it_down_innit_bruv = yes }
			OR = {
				AND = {
					has_in_house_alchemy = yes
					wealth = 40
				}
				wealth = 60
			}
		}
		effect = {
			if = {
				limit = {
					has_in_house_alchemy = yes
				}
				wealth = -40
			}
			if = {
				limit = {
					NOT = { has_in_house_alchemy = yes }
				}
				wealth = -60
			}
			add_character_modifier = { name = modifier_potion_of_chameleon years = 5 }
			
			character_event = { id = moarek.100 days = 1830 } #they have to be in days since they can only drink another potion AFTER the first wears off	
		}
	}
	
	alch_potion_of_longevity = {
		ai_check_interval = 12000
		only_playable = yes
		ai = no
		
		potential = {
			OR = {
				has_character_flag = alchemist_open
				#ai = yes
			}
			NOT = { has_character_modifier = modifier_potion_of_longevity }
		}
		allow = {
			prisoner = no
			NOT = { chugged_it_down_innit_bruv = yes }
			OR = {
				AND = {
					has_in_house_alchemy = yes
					wealth = 80
				}
				wealth = 150
			}
		}
		effect = {
			if = {
				limit = {
					has_in_house_alchemy = yes
				}
				wealth = -80
			}
			if = {
				limit = {
					NOT = { has_in_house_alchemy = yes }
				}
				wealth = -150
			}
			add_character_modifier = { name = modifier_potion_of_longevity years = 2 }
			health = 0.25
			
			character_event = { id = moarek.101 days = 735 }		
		}
	}
	
	alch_potion_of_fortify_health = {
		ai_check_interval = 12000
		only_playable = yes
		ai = no
		
		potential = {
			OR = {
				has_character_flag = alchemist_open
				#ai = yes
			}
			NOT = { has_character_modifier = modifier_potion_of_fortify_health }
		}
		allow = {
			prisoner = no
			NOT = { chugged_it_down_innit_bruv = yes }
			OR = {
				AND = {
					has_in_house_alchemy = yes
					wealth = 250
				}
				wealth = 400 #This is a really huge buff.
			}
		}
		effect = {
			if = {
				limit = {
					has_in_house_alchemy = yes
				}
				wealth = -250
			}
			if = {
				limit = {
					NOT = { has_in_house_alchemy = yes }
				}
				wealth = -400
			}
			add_character_modifier = { name = modifier_potion_of_fortify_health years = 5 }
			
			character_event = { id = moarek.102 days = 1830 }
		}
	}
	
	alch_potion_of_virility = {
		ai_check_interval = 12000
		only_playable = yes
		ai = no
		
		potential = {
			OR = {
				has_character_flag = alchemist_open
				#ai = yes
			}
			NOT = { has_character_modifier = modifier_potion_of_virility }
		}
		allow = {
			prisoner = no
			NOT = { chugged_it_down_innit_bruv = yes }
			OR = {
				AND = {
					has_in_house_alchemy = yes
					wealth = 80
				}
				wealth = 150
			}
		}
		effect = {
			if = {
				limit = {
					has_in_house_alchemy = yes
				}
				wealth = -80
			}
			if = {
				limit = {
					NOT = { has_in_house_alchemy = yes }
				}
				wealth = -150
			}
			add_character_modifier = { name = modifier_potion_of_virility years = 3 }
			
			character_event = { id = moarek.103 days = 1100 }
		}
	}
	
	alch_potion_of_fortify_strength = {
		ai_check_interval = 12000
		only_playable = yes
		ai = no
		
		potential = {
			OR = {
				has_character_flag = alchemist_open
				#ai = yes
			}
			NOT = { has_character_modifier = modifier_potion_of_fortify_strength }
		}
		allow = {
			prisoner = no
			NOT = { chugged_it_down_innit_bruv = yes }
			OR = {
				AND = {
					has_in_house_alchemy = yes
					wealth = 125
				}
				wealth = 250
			}
		}
		effect = {
			if = {
				limit = {
					has_in_house_alchemy = yes
				}
				wealth = -125
			}
			if = {
				limit = {
					NOT = { has_in_house_alchemy = yes }
				}
				wealth = -250
			}
			add_character_modifier = { name = modifier_potion_of_fortify_strength years = 3 }
			
			character_event = { id = moarek.104 days = 1100 }
		}
	}
	
	alch_potion_of_fortify_personality = {
		ai_check_interval = 12000
		only_playable = yes
		ai = no
		
		potential = {
			OR = {
				has_character_flag = alchemist_open
				#ai = yes
			}
			NOT = { has_character_modifier = modifier_potion_of_fortify_personality }
		}
		allow = {
			prisoner = no
			NOT = { chugged_it_down_innit_bruv = yes }
			OR = {
				AND = {
					has_in_house_alchemy = yes
					wealth = 125
				}
				wealth = 250
			}
		}
		effect = {
			if = {
				limit = {
					has_in_house_alchemy = yes
				}
				wealth = -125
			}
			if = {
				limit = {
					NOT = { has_in_house_alchemy = yes }
				}
				wealth = -250
			}
			add_character_modifier = { name = modifier_potion_of_fortify_personality years = 3 }
			
			character_event = { id = moarek.105 days = 1100 }
		}
	}
	
	alch_potion_of_fortify_luck = {
		ai_check_interval = 12000
		only_playable = yes
		ai = no
		
		potential = {
			OR = {
				has_character_flag = alchemist_open
				#ai = yes
			}
			NOT = { has_character_modifier = modifier_potion_of_fortify_luck }
		}
		allow = {
			prisoner = no
			NOT = { chugged_it_down_innit_bruv = yes }
			OR = {
				AND = {
					has_in_house_alchemy = yes
					wealth = 100
				}
				wealth = 180
			}
		}
		effect = {
			if = {
				limit = {
					has_in_house_alchemy = yes
				}
				wealth = -100
			}
			if = {
				limit = {
					NOT = { has_in_house_alchemy = yes }
				}
				wealth = -180
			}
			add_character_modifier = { name = modifier_potion_of_fortify_luck years = 3 }
			
			character_event = { id = moarek.106 days = 1100 }
		}
	}
	
	alch_potion_of_fortify_intelligence = {
		ai_check_interval = 12000
		only_playable = yes
		ai = no
		
		potential = {
			OR = {
				has_character_flag = alchemist_open
				#ai = yes
			}
			NOT = { has_character_modifier = modifier_potion_of_fortify_intelligence }
		}
		allow = {
			prisoner = no
			NOT = { chugged_it_down_innit_bruv = yes }
			OR = {
				AND = {
					has_in_house_alchemy = yes
					wealth = 100
				}
				wealth = 180
			}
		}
		effect = {
			if = {
				limit = {
					has_in_house_alchemy = yes
				}
				wealth = -100
			}
			if = {
				limit = {
					NOT = { has_in_house_alchemy = yes }
				}
				wealth = -180
			}
			add_character_modifier = { name = modifier_potion_of_fortify_intelligence years = 3 }
			
			character_event = { id = moarek.107 days = 1100 }
		}
	}
	
	alch_potion_of_fortify_agility = {
		ai_check_interval = 12000
		only_playable = yes
		ai = no
		
		potential = {
			OR = {
				has_character_flag = alchemist_open
				#ai = yes
			}
			NOT = { has_character_modifier = modifier_potion_of_fortify_agility }
		}
		allow = {
			prisoner = no
			NOT = { chugged_it_down_innit_bruv = yes }
			OR = {
				AND = {
					has_in_house_alchemy = yes
					wealth = 100
				}
				wealth = 180
			}
		}
		effect = {
			if = {
				limit = {
					has_in_house_alchemy = yes
				}
				wealth = -100
			}
			if = {
				limit = {
					NOT = { has_in_house_alchemy = yes }
				}
				wealth = -180
			}
			add_character_modifier = { name = modifier_potion_of_fortify_agility years = 3 }
			
			character_event = { id = moarek.108 days = 1100 }
		}
	}
	
	alch_potion_of_restore_magicka = {
		ai_check_interval = 12000
		only_playable = yes
		ai = no
		
		potential = {
			OR = {
				has_character_flag = alchemist_open
				#ai = yes
			}
			NOT = { has_character_modifier = modifier_potion_of_restore_magicka }
		}
		allow = {
			prisoner = no
			NOT = { chugged_it_down_innit_bruv = yes }
			OR = {
				AND = {
					has_in_house_alchemy = yes
					wealth = 80
				}
				wealth = 150
			}
		}
		effect = {
			if = {
				limit = {
					has_in_house_alchemy = yes
				}
				wealth = -80
			}
			if = {
				limit = {
					NOT = { has_in_house_alchemy = yes }
				}
				wealth = -150
			}
			add_character_modifier = { name = modifier_potion_of_restore_magicka years = 2 }
		}
	}	
	
	alch_potion_of_skooma = {
		ai_check_interval = 12000
		only_playable = yes
		ai = no
		
		potential = {
			OR = {
				has_character_flag = alchemist_open
			}
			NOT = { has_character_modifier = modifier_potion_of_skooma_10 }
		}
		allow = {
			prisoner = no
			OR = {
				AND = {
					has_in_house_alchemy = yes
					wealth = 20
				}
				wealth = 40
			}
		}
		effect = {
			if = {
				limit = {
					has_in_house_alchemy = yes
				}
				wealth = -20
			}
			if = {
				limit = {
					NOT = { has_in_house_alchemy = yes }
				}
				wealth = -40
			}
			if = {
				limit = {
					NOT = { trait = skooma_addiction } #if your not an addict bad stuff can happen
				}
				random_list = {
					50 = {}	
					10 = { change_martial = 1 }				
					25 = { change_learning = -1 }
					10 = { 
						health = -0.01 					
					}
					5 = { 
						add_trait = skooma_addiction 					
					}
				}
			}	
			if = {
				limit = {
					trait = skooma_addiction #if your an addict bad stuff is less likely to happen
				}
				random_list = {
					75 = {}	
					15 = { change_martial = 1 }				
					10 = { change_learning = -1 }
				}
			}
			ROOT = {
				if = {
					limit = {
						NOT = { has_character_modifier = modifier_potion_of_skooma }
					}
					add_character_modifier = { name = modifier_potion_of_skooma years = 2 }
				}	
				else_if = {
					limit = {
						NOT = { has_character_modifier = modifier_potion_of_skooma_1 }
					}
					add_character_modifier = { name = modifier_potion_of_skooma_1 years = 2 }
				}	
				else_if = {
					limit = {
						NOT = { has_character_modifier = modifier_potion_of_skooma_2 }
					}
					add_character_modifier = { name = modifier_potion_of_skooma_2 years = 2 }
				}
				else_if = {
					limit = {
						NOT = { has_character_modifier = modifier_potion_of_skooma_3 }
					}
					add_character_modifier = { name = modifier_potion_of_skooma_3 years = 2 }
				}
				else_if = {
					limit = {
						NOT = { has_character_modifier = modifier_potion_of_skooma_4 }
					}
					add_character_modifier = { name = modifier_potion_of_skooma_4 years = 2 }
				}
				else_if = {
					limit = {
						NOT = { has_character_modifier = modifier_potion_of_skooma_5 }
					}
					add_character_modifier = { name = modifier_potion_of_skooma_5 years = 2 }
				}
				else_if = {
					limit = {
						NOT = { has_character_modifier = modifier_potion_of_skooma_6 }
					}
					add_character_modifier = { name = modifier_potion_of_skooma_6 years = 2 }
				}
				else_if = {
					limit = {
						NOT = { has_character_modifier = modifier_potion_of_skooma_7 }
					}
					add_character_modifier = { name = modifier_potion_of_skooma_7 years = 2 }
				}
				else_if = {
					limit = {
						NOT = { has_character_modifier = modifier_potion_of_skooma_8 }
					}
					add_character_modifier = { name = modifier_potion_of_skooma_8 years = 2 }
				}
				else_if = {
					limit = {
						NOT = { has_character_modifier = modifier_potion_of_skooma_9 }
					}
					add_character_modifier = { name = modifier_potion_of_skooma_9 years = 2 }
				}
				else = {
					add_character_modifier = { name = modifier_potion_of_skooma_10 years = 2 }
				}
			}
		}
	}	
	
	alch_potion_of_regeneration = { #Advanced potion, requires in-house alchemy
		ai_check_interval = 12000
		only_playable = yes
		ai = no
		
		potential = {
			OR = {
				has_character_flag = alchemist_open
				#ai = yes
			}
			NOT = { has_character_modifier = modifier_potion_of_regeneration }
		}
		allow = {
			prisoner = no
			NOT = { chugged_it_down_innit_bruv = yes }
			has_in_house_alchemy = yes
			wealth = 600
			health >= 5
			is_maimed_trigger = yes
		}
		effect = {
			wealth = -600
			add_character_modifier = { name = modifier_potion_of_regeneration years = 2 }
			random_list = {
				10 = {
					remove_trait = maimed
					modifier = {
						NOT = { trait = maimed }
						factor = 0
					}
				}
				10 = {
					remove_trait = one_legged
					modifier = {
						NOT = { trait = one_legged }
						factor = 0
					}
				}
				10 = {
					remove_trait = one_eyed
					modifier = {
						NOT = { trait = one_eyed }
						factor = 0
					}
				}
				10 = {
					remove_trait = one_handed
					modifier = {
						NOT = { trait = one_handed }
						factor = 0
					}
				}
				10 = {
					remove_trait = mangled
					modifier = {
						NOT = { trait = mangled }
						factor = 0
					}
				}
				10 = {
					remove_trait = disfigured
					modifier = {
						NOT = { trait = disfigured }
						factor = 0
					}
				}
			}
		}
	}
	
	alch_potion_of_genderswap = { #Advanced potion, requires in-house alchemy
		ai_check_interval = 12000
		only_playable = yes
		ai = no
		
		potential = {
			OR = {
				has_character_flag = alchemist_open
				#ai = yes
			}
			NOT = { has_character_modifier = modifier_potion_of_genderswap }
		}
		allow = {
			prisoner = no
			NOT = { chugged_it_down_innit_bruv = yes }
			has_in_house_alchemy = yes
			wealth = 800
			health >= 5
			eligible_for_genderswap = yes
		}
		effect = {
			wealth = -800
			add_character_modifier = { name = modifier_potion_of_genderswap years = 5 }
			health = -0.5 #Better start chugging longevity potions.
			swap_character_sex = yes
		}
	}
}