society_decisions = { 
	#Dummy
	guilds_buffing_dummy = {
		only_playable = yes

		only_rulers = yes
		potential = {
			always = no
		}

		allow = {
		}
		
		effect = {
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	guilds_sabotaging_dummy = {
		only_playable = yes

		only_rulers = yes
		potential = {
			always = no
		}

		allow = {
		}
		
		effect = {
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	request_to_rank_up_within_guilds = {

		ai_check_interval = 12
		hide_in_decisions_list = yes # This is shown in the Society View
		
		potential = {
			hidden_tooltip = {
				society_rank < 4
				days_in_society > 365
				#has_dlc = "Mystics"
				is_in_society = yes
				OR = { #Players can always rank up (if they have the power)
					ai = no
					AND = {
						ai = yes
						society_can_rank_up = yes
					}
				}
			}
		}

		allow = {
			#Rank requirements. IMPORTANT!!! If you change the requirements, the customizable loc keys "GetSocietyRankUpTooltip" 1, 2, 3, and 4 must be updated, as it displays these requirements.
			custom_tooltip = { # Sufficient currency
				text = request_to_rank_up_within_guilds_currency_tt
				OR = {
					AND = {
						society_rank == 1
						OR = {
							society_currency >= 750
							AND = {
								society_currency >= 325
								OR = {
									any_owned_bloodline = {
										has_bloodline_flag = the_guilds
									}
									trait = guilds_trait_apprentice
								}
							}
						}
					}
					AND = {
						society_rank == 2
						OR = {
							society_currency >= 1000
							AND = {
								society_currency >= 500
								OR = {
									any_owned_bloodline = {
										has_bloodline_flag = the_guilds
									}
									trait = guilds_trait_trader
								}
							}
						}
					}
					OR = {
						society_currency >= 2000 # rank 3
							AND = {
								society_currency >= 1000
								OR = {
									any_owned_bloodline = {
										has_bloodline_flag = the_guilds
									}
									trait = guilds_trait_master
								}
							}
					}
				}
			}

			custom_tooltip = {
				text = must_not_have_sent_request_already_tooltip 
				NOT = { has_character_flag = has_sent_request_to_rank_up }
			}

			custom_tooltip = {
				text = must_be_allowed_to_rank_up_tooltip 
				days_at_current_society_rank >= 1095 #IMPORTANT! Update tooltip.
			}

			custom_tooltip = {
				text = must_have_grandmaster_tooltip #You must have a grand master
				any_society_member = {
					is_society_grandmaster = yes
					same_society_as = ROOT
				}
			}
		}

		effect = {
			#Rank up cost
			if = {
				limit = { 
					society_rank == 1 
					OR = {
						trait = guilds_trait_apprentice
						any_owned_bloodline = {
							has_bloodline_flag = the_guilds
						}
					}
				}
				change_society_currency = -325
			}
			if = {
				limit = { 
					society_rank == 2 
					OR ={ 
						trait = guilds_trait_trader
						any_owned_bloodline = {
							has_bloodline_flag = the_guilds
						}
					}
				}
				change_society_currency = -500
			}
			if = {
				limit = { 
					society_rank == 3 
					OR ={ 
						trait = guilds_trait_master
						any_owned_bloodline = {
							has_bloodline_flag = the_guilds
						}
					}
				}
				change_society_currency = -1000
			}
			if = {
				limit = { 
					society_rank == 1 
					NOT = { trait = guilds_trait_apprentice }
				}
				change_society_currency = -750
			}
			if = {
				limit = { 
					society_rank == 2 
					NOT = { trait = guilds_trait_trader }
				}
				change_society_currency = -1000
			}
			if = {
				limit = { 
					society_rank == 3 
					NOT = { trait = guilds_trait_master }
				}
				change_society_currency = -2000
			}

			#Perform rank up
			hidden_tooltip = {
				save_event_target_as = rank_up_target
				set_character_flag = has_sent_request_to_rank_up
				character_event = { id = SNW.120 days = 20 random = 10 } # sends hidden delayed event to self, which then sends request to Leader of the society
				
			}
		}

		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1

			modifier = {
				factor = 0.05 #Slow down
			}
			modifier = {
				factor = 0.5
				trait = content
			}
			modifier = {
				factor = 2 
				trait = ambitious
			}
		}
	}
	guilds_shopping_caravan_ai = { #so they do not check tons of provinces every years
		
		ai_check_interval = 12
		only_rulers = yes
		potential = {
			ai = yes
			society_member_of = the_guilds 
			society_rank >= 3
			is_landed = yes
			has_artifact = guilds_item_shop_caravan
			is_inaccessible_or_incapable_guilds_trigger = yes
		}
		allow = {
			has_society_currency_minor_trigger = yes
			NOT = { has_character_flag = guilds_preparing_caravan }
			NOR = { 
				has_character_modifier = guilds_highway_robber_band 
				has_character_flag = guilds_robber_caravan
			}
		}
		
		effect = {
			detract_society_currency_minor_effect = yes
			destroy_artifact = guilds_item_shop_caravan
			clr_character_flag = guilds_prepared_caravan
			if = {
				limit = { has_character_modifier = guilds_highway_robber_band_military }
				scaled_wealth = -0.5
			}
			hidden_tooltip = {  #too complicated, hidden tooltip
				if = {
					limit = {
						ROOT = { 
							capital_holding = {
								has_holding_modifier = guilds_caravan_escort
							}
						}
					}
					ROOT = {
						capital_holding  = {
							remove_holding_modifier = guilds_caravan_escort
						}
					}
					ROOT = { 
						capital_holding  = {
							add_holding_modifier = {
								name = guilds_caravan_escort
								months = 24
							}
						}
					}
				}
				ROOT = { 
					add_character_modifier = {
							name = guilds_caravan_timer
							duration = 200
							hidden = yes
					}
				}
				random_list = {
					10 = {
						modifier = {
							factor = 0.5
							has_character_flag = guilds_caravan_investment_security
						}
						modifier = {
							factor = 4
							has_character_modifier = guilds_highway_robber_band_dare
						}
						character_event = { id = SNW.193 days = 300 }  #caravan missing
						if = {
							limit = {
								has_quest = quest_guilds_caravan
							}
							character_event = { id = SNW.425 days = 300 }  #complete mission
						}
					}
					90 = {
						character_event = { id = SNW.190 days = 360 }  #caravan return
						if = {
							limit = {
								has_quest = quest_guilds_caravan
							}
							character_event = { id = SNW.422 days = 360 }  #complete mission
						}
						random_province = {
							limit = {
								owner = { NOT = { character = ROOT } }
								OR = {
									holding_type = tribal
									holding_type = temple
									holding_type = castle
									holding_type = city
									holding_type = nomad
								}
								OR = {
									has_province_modifier = guilds_buff_stone
									has_province_modifier = guilds_buff_steel
									has_province_modifier = guilds_buff_gem
									has_province_modifier = guilds_buff_silver
									has_province_modifier = guilds_buff_gold
									has_province_modifier = guilds_buff_grain
									has_province_modifier = guilds_buff_lumber
									has_province_modifier = guilds_buff_incense
									has_province_modifier = guilds_buff_spices
									has_province_modifier = guilds_buff_meat
									has_province_modifier = guilds_buff_wool
									has_province_modifier = guilds_buff_hide
									has_province_modifier = guilds_buff_ivory
									has_province_modifier = guilds_buff_silk
									has_province_modifier = guilds_buff_pottery
									has_province_modifier = guilds_buff_alcohol
									has_province_modifier = guilds_buff_armor
									has_province_modifier = guilds_buff_jewelry
									has_province_modifier = guilds_buff_book
									has_province_modifier = guilds_buff_statue
									has_province_modifier = guilds_buff_music
									has_province_modifier = guilds_buff_glassware
									has_province_modifier = guilds_buff_dye
									has_province_modifier = guilds_buff_velvet
									has_province_modifier = guilds_buff_fur
								}
								NOT = { has_province_modifier = guilds_shop_caravan }
							}
							location = {
								add_province_modifier = {
									name = guilds_shop_caravan
									months = 24
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_stone							}
								random_list = {
									10 = { }
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1901 days = 365 } }
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_steel							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1902 days = 365 } } 
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_gem							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1903 days = 365 } } 
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_silver							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1904 days = 365 } } 
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_gold							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1905 days = 365 } } 
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_grain							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1906 days = 365 } } 
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_lumber							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1907 days = 365 } } 
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_linen							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1908 days = 365 } } 
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_incense							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1909 days = 365 } } 
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_spices							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1910 days = 365 } } 
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_meat							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1911 days = 365 } } 
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_wool							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1912 days = 365 } } 
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_hide							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1913 days = 365 } } 
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_ivory							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1914 days = 365 } } 
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_silk							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1915 days = 365 } } 
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_pottery							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1916 days = 365 } } 
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_alcohol							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1917 days = 365 } } 
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_armor							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1918 days = 365 } } 
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_jewelry							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1919 days = 365 } } 
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_book							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1920 days = 365 } }
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_statue							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1921 days = 365 } }
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_music							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1922 days = 365 } }
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_glassware							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1923 days = 365 } }
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_dye							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1924 days = 365 } }
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_velvet							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1925 days = 365 } }
									}
								}
							}
							if = {
								limit = {
									has_province_modifier = guilds_buff_fur							}
								random_list = {
									10 = { } 
									10 = { # 50% chance of failure
										modifier = { 
											factor = 2.3 #~30% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_small }
										}
										modifier = {
											factor = 10 #~11% chance of failure
											ROOT = { has_character_flag = guilds_caravan_investment_large }
										}
										ROOT = { character_event = { id = SNW.1926 days = 365 } }
									}
								}
							}
						}
					}
				}
			}
			ROOT = { character_event = { id = SNW.199 }  } #hidden remove flags
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				has_character_modifier = guilds_caravan_timer
			}
		}
	}
	guilds_shipping_goods_ai = { #so they do not check 25 decisions for each of their provinces every year
		
		ai_check_interval = 6
		only_rulers = yes
		potential = {
			ai = yes
			society_member_of = the_guilds
			society_rank >= 2
			is_landed = yes
			is_inaccessible_or_incapable_guilds_trigger = yes
		}
		
		allow = {
			any_artifact = {
				has_artifact_flag = goods
			}
		}
		
		effect = {
			random_demesne_title = {
				limit = {
					NOT = { holding_type = family_palace }
					lower_tier_than = duke
					OR = {
						AND = {
							ROOT = { is_nomadic = yes }
							location = { capital_holding = { holding_type = nomad } }
						}
						ROOT = { is_nomadic = no }
					}
				}
				location = {
					random_list = {
						1 = { } #overflow
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_stone }
								NOT = { has_province_modifier = guilds_buff_stone }
								NOT = { has_province_modifier = guilds_smugglers_ring_metal }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.04 min = 4 max = 40 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_stone
							}
							add_province_modifier = {
								name = guilds_buff_stone
								months = 12
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_steel }
								NOT = { has_province_modifier = guilds_buff_steel }
								NOT = { has_province_modifier = guilds_smugglers_ring_metal }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.25 min = 25 max = 250 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_steel
							}
							add_province_modifier = {
								name = guilds_buff_steel
								months = 24
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_gem }
								NOT = { has_province_modifier = guilds_buff_gem }
								NOT = { has_province_modifier = guilds_smugglers_ring_metal }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.45 min = 45 max = 450 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_gem
							}
							add_province_modifier = {
								name = guilds_buff_gem
								months = 36
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_silver }
								NOT = { has_province_modifier = guilds_buff_silver }
								NOT = { has_province_modifier = guilds_smugglers_ring_metal }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.65 min = 65 max = 650 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_silver
							}
							add_province_modifier = {
								name = guilds_buff_silver
								months = 48
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_gold }
								NOT = { has_province_modifier = guilds_buff_gold }
								NOT = { has_province_modifier = guilds_smugglers_ring_metal }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.85 min = 85 max = 850 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_gold
							}
							add_province_modifier = {
								name = guilds_buff_gold
								months = 60
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_grain }
								NOT = { has_province_modifier = guilds_buff_grain }
								NOT = { has_province_modifier = guilds_smugglers_ring_vegetal }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.04 min = 4 max = 40 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_grain
							}
							add_province_modifier = {
								name = guilds_buff_grain
								months = 12
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_lumber }
								NOT = { has_province_modifier = guilds_buff_lumber }
								NOT = { has_province_modifier = guilds_smugglers_ring_vegetal }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.25 min = 25 max = 250 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_lumber
							}
							add_province_modifier = {
								name = guilds_buff_lumber
								months = 24
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_linen }
								NOT = { has_province_modifier = guilds_buff_linen }
								NOT = { has_province_modifier = guilds_smugglers_ring_vegetal }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.45 min = 45 max = 450 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_linen
							}
							add_province_modifier = {
								name = guilds_buff_linen
								months = 36
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_incense }
								NOT = { has_province_modifier = guilds_buff_incense }
								NOT = { has_province_modifier = guilds_smugglers_ring_vegetal }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.65 min = 65 max = 650 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_incense
							}
							add_province_modifier = {
								name = guilds_buff_incense
								months = 48
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_spices }
								NOT = { has_province_modifier = guilds_buff_spices }
								NOT = { has_province_modifier = guilds_smugglers_ring_vegetal }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.85 min = 85 max = 850 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_spices
							}
							add_province_modifier = {
								name = guilds_buff_spices
								months = 60
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_meat }
								NOT = { has_province_modifier = guilds_buff_meat }
								NOT = { has_province_modifier = guilds_smugglers_ring_animal }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.04 min = 4 max = 40 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_meat
							}
							add_province_modifier = {
								name = guilds_buff_meat
								months = 12
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_wool }
								NOT = { has_province_modifier = guilds_buff_wool }
								NOT = { has_province_modifier = guilds_smugglers_ring_animal }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.25 min = 25 max = 250 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_wool
							}
							add_province_modifier = {
								name = guilds_buff_wool
								months = 24
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_hide }
								NOT = { has_province_modifier = guilds_buff_hide }
								NOT = { has_province_modifier = guilds_smugglers_ring_animal }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.45 min = 45 max = 450 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_hide
							}
							add_province_modifier = {
								name = guilds_buff_hide
								months = 36
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_ivory }
								NOT = { has_province_modifier = guilds_buff_ivory }
								NOT = { has_province_modifier = guilds_smugglers_ring_animal }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.65 min = 65 max = 650 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_ivory
							}
							add_province_modifier = {
								name = guilds_buff_ivory
								months = 48
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_silk }
								NOT = { has_province_modifier = guilds_buff_silk }
								NOT = { has_province_modifier = guilds_smugglers_ring_animal }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.85 min = 85 max = 850 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_silk
							}
							add_province_modifier = {
								name = guilds_buff_silk
								months = 60
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_pottery }
								NOT = { has_province_modifier = guilds_buff_pottery }
								NOT = { has_province_modifier = guilds_smugglers_ring_final }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.04 min = 4 max = 40 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_pottery
							}
							add_province_modifier = {
								name = guilds_buff_pottery
								months = 12
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_alcohol }
								NOT = { has_province_modifier = guilds_buff_alcohol }
								NOT = { has_province_modifier = guilds_smugglers_ring_final }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.25 min = 25 max = 250 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_alcohol
							}
							add_province_modifier = {
								name = guilds_buff_alcohol
								months = 24
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_armor }
								NOT = { has_province_modifier = guilds_buff_armor }
								NOT = { has_province_modifier = guilds_smugglers_ring_final }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.45 min = 45 max = 450 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_armor
							}
							add_province_modifier = {
								name = guilds_buff_armor
								months = 36
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_jewelry }
								NOT = { has_province_modifier = guilds_buff_jewelry }
								NOT = { has_province_modifier = guilds_smugglers_ring_final }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.65 min = 65 max = 650 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_jewelry
							}
							add_province_modifier = {
								name = guilds_buff_jewelry
								months = 48
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_book }
								NOT = { has_province_modifier = guilds_buff_book }
								NOT = { has_province_modifier = guilds_smugglers_ring_final }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.85 min = 85 max = 850 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_book
							}
							add_province_modifier = {
								name = guilds_buff_book
								months = 60
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_statue }
								NOT = { has_province_modifier = guilds_buff_statue }
								NOT = { has_province_modifier = guilds_smugglers_ring_metal }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.25 min = 25 max = 250 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_statue
							}
							add_province_modifier = {
								name = guilds_buff_statue
								months = 24
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_music }
								NOT = { has_province_modifier = guilds_buff_music }
								NOT = { has_province_modifier = guilds_smugglers_ring_final }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.65 min = 65 max = 650 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_music
							}
							add_province_modifier = {
								name = guilds_buff_music
								months = 48
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_glassware }
								NOT = { has_province_modifier = guilds_buff_glassware }
								NOT = { has_province_modifier = guilds_smugglers_ring_final }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.65 min = 65 max = 650 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_glassware
							}
							add_province_modifier = {
								name = guilds_buff_glassware
								months = 48
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_velvet }
								NOT = { has_province_modifier = guilds_buff_velvet }
								NOT = { has_province_modifier = guilds_smugglers_ring_final }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.65 min = 65 max = 650 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_velvet
							}
							add_province_modifier = {
								name = guilds_buff_velvet
								months = 48
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_fur }
								NOT = { has_province_modifier = guilds_buff_fur }
								NOT = { has_province_modifier = guilds_smugglers_ring_animal }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.65 min = 65 max = 650 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_fur
							}
							add_province_modifier = {
								name = guilds_buff_fur
								months = 48
							}
						}
						10 = {
							trigger = {
								ROOT = { has_artifact = guilds_item_dye }
								NOT = { has_province_modifier = guilds_buff_dye }
								NOT = { has_province_modifier = guilds_smugglers_ring_final }
							}
							ROOT = { 
								change_variable = { which = guildsxp value = 1 }
								scaled_wealth = { value = 0.85 min = 85 max = 850 } #simplified for AIs, not counting stalls/terrain but higher gold baseline.
								destroy_artifact = guilds_item_dye
							}
							add_province_modifier = {
								name = guilds_buff_dye
								months = 60
							}
						}
					}
				}
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	#Show decisions
	guilds_show_decisions_on = {
		# is_in_society = yes
		
		only_rulers = yes
		potential = {
			OR = {
				is_landed = yes
				is_patrician = yes
			}
			society_member_of = the_guilds
			society_rank >= 1
			NOT = { has_character_flag = guilds_show_decision }
		}

		allow = {
		}

		effect = {
			set_character_flag = guilds_show_decision
			sound_effect = turning_page
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 1
		}
	}
	#hide decisions
	guilds_show_decisions_off = {
		# is_in_society = yes
		ai = no
		only_rulers = yes
		potential = {
			OR = {
				is_landed = yes
				is_patrician = yes
			}
			society_member_of = the_guilds
			society_rank >= 1
			has_character_flag = guilds_show_decision
		}

		allow = {
		}

		effect = {
			clr_character_flag = guilds_show_decision
			sound_effect = letter_event
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 0
		}
	}
#Go shopping / Loan / Buy stall / Republic
	guilds_shopping = { 
		
		only_rulers = yes
		ai_check_interval = 6
		potential = {
			OR = {
				is_landed = yes
				is_patrician = yes
			}
			society_member_of = the_guilds
			society_rank >= 1
			has_character_flag = guilds_show_decision
		}

		allow = {
			is_inaccessible_or_incapable_guilds_trigger = yes
			influence_cost_shopping_trigger = yes
			custom_tooltip = {
				text = guilds_shopping_cooldown_tooltip
				NOT = {
					has_character_modifier = guilds_shopping_timer
				}
				NOT = {
					has_character_flag = guilds_is_using_goods
				}
			}
		}

		effect = {
			# set_character_flag = do_not_disturb
			hidden_tooltip = {
				character_event = { id = SNW.130 } 
				add_character_modifier = {
					name = guilds_shopping_timer
					duration = 100
					hidden = yes
				}
			}
			influence_cost_shopping_effect = yes
			hidden_tooltip = {
				if = {
					limit = {
						check_variable = { which = guildsxp value >= 10 }
						NOT = { trait = guilds_trait_apprentice }
						NOT = { trait = guilds_trait_trader }
						NOT = { trait = guilds_trait_master }
						NOT = { has_character_flag = guilds_refuse_traits }
					}
				character_event = { id = SNW.250 days = 70 }
				}
				if = {
					limit = {
						check_variable = { which = guildsxp value >= 25 }
						trait = guilds_trait_apprentice
						NOT = { has_character_flag = guilds_refuse_traits }
					}
				character_event = { id = SNW.251 days = 70 }
				}
				if = {
					limit = {
						check_variable = { which = guildsxp value >= 45 }
						trait = guilds_trait_trader
						NOT = { has_character_flag = guilds_refuse_traits }
					}
				character_event = { id = SNW.252 days = 70 }
				}
			}
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 0.5

			modifier = {
				factor = 0.5
				is_dumb_trigger = yes
			}
			modifier = {
				factor = 1.5
				trait = greedy
			}

			modifier = {
				factor = 2
				scaled_wealth = 2
			}
		}
	}
#Loan
	guilds_loaning_one = {
		ai_check_interval = 6
		only_rulers = yes
		potential = {
			society_member_of = the_guilds
			society_rank >= 1
			# higher_tier_than = baron
			NOT = {
				has_character_modifier = guilds_loan_one
			}
			has_character_flag = guilds_show_decision
		}

		allow = {
			is_inaccessible_or_incapable_guilds_trigger = yes
			influence_cost_shopping_trigger = yes
			custom_tooltip = {
				text = guilds_loan_cooldown_tooltip
				NAND = {
					has_character_modifier = guilds_loan_one
					has_character_modifier = guilds_loan_two
					has_character_modifier = guilds_loan_three
				}
			}
		}

		effect = {
			wealth = 100
			influence_cost_shopping_effect = yes
			if = {
				limit = {
					wealth >= 0
				}
				character_event = { id = SNW.1501 days = 720 }
				add_character_modifier = {
					modifier = guilds_loan_one
					days = 720
					inherit = yes
				}
			}
			if = {
				limit = {
					NOT = { wealth >= 0 }
				}
				character_event = { id = SNW.1511 days = 720 }
				add_character_modifier = {
					modifier = guilds_loan_one
					days = 720
					inherit = yes
				}
			}
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 0.5
			modifier = {
				factor = 2
				NOT = { wealth >= 0 }
				war = yes
			}
			modifier = {
				factor = 0
				wealth = 0
				war = no
			}
			modifier = {
				factor = 0
				wealth = 200
				war = yes
			}
		}
	}
	guilds_loaning_two = {
		ai_check_interval = 6
		only_rulers = yes
		potential = {
			society_member_of = the_guilds
			society_rank >= 1
			# higher_tier_than = baron
			has_character_modifier = guilds_loan_one
			NOT = {
				has_character_modifier = guilds_loan_two
			}
			has_character_flag = guilds_show_decision
		}

		allow = {
			is_inaccessible_or_incapable_guilds_trigger = yes
			influence_cost_shopping_trigger = yes
			custom_tooltip = {
				text = guilds_loan_cooldown_tooltip
				NAND = {
					has_character_modifier = guilds_loan_one
					has_character_modifier = guilds_loan_two
					has_character_modifier = guilds_loan_three
				}
			}
		}

		effect = {
			wealth = 100
			influence_cost_shopping_effect = yes
			if = {
				limit = {
					wealth >= 0
				}
				character_event = { id = SNW.1501 days = 725 }
				add_character_modifier = {
					modifier = guilds_loan_two
					days = 725
					inherit = yes
				}
			}
			if = {
				limit = {
					NOT = { wealth >= 0 }
				}
				character_event = { id = SNW.1511 days = 725 }
				add_character_modifier = {
					modifier = guilds_loan_two
					days = 725
					inherit = yes
				}
			}
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 0.5
			modifier = {
				factor = 2
				NOT = { wealth >= 0 }
				war = yes
			}
			modifier = {
				factor = 0
				wealth = 0
				war = no
			}
			modifier = {
				factor = 0
				wealth = 200
				war = yes
			}
		}
	}
	guilds_loaning_three = {
		ai_check_interval = 6
		only_rulers = yes
		potential = {
			society_member_of = the_guilds
			society_rank >= 1
			# higher_tier_than = baron
			has_character_modifier = guilds_loan_one
			has_character_modifier = guilds_loan_two
			NOT = {
				has_character_modifier = guilds_loan_three
			}
			has_character_flag = guilds_show_decision
		}
 
		allow = {
			is_inaccessible_or_incapable_guilds_trigger = yes
			influence_cost_shopping_trigger = yes
			custom_tooltip = {
				text = guilds_loan_cooldown_tooltip
				NAND = {
					has_character_modifier = guilds_loan_one
					has_character_modifier = guilds_loan_two
					has_character_modifier = guilds_loan_three
				}
			}
		}

		effect = {
			wealth = 100
			influence_cost_shopping_effect = yes
			if = {
				limit = {
					wealth >= 0
				}
				character_event = { id = SNW.1501 days = 730 }
				add_character_modifier = {
					modifier = guilds_loan_three
					days = 730
					inherit = yes
				}
			}
			if = {
				limit = {
					NOT = { wealth >= 0 }
				}
				character_event = { id = SNW.1511 days = 730 }
				add_character_modifier = {
					modifier = guilds_loan_three
					days = 730
					inherit = yes
				}
			}
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 0.5
			modifier = {
				factor = 2
				NOT = { wealth >= 0 }
				war = yes
			}
			modifier = {
				factor = 0
				wealth = 0
				war = no
			}
			modifier = {
				factor = 0
				wealth = 200
				war = yes
			}
		}
	}
#Caravan Stall shop
	guilds_buy_shop = {
		ai_check_interval = 12
		only_rulers = yes
		potential = {
			OR = {
				is_landed = yes
				is_patrician = yes
			}
			society_member_of = the_guilds
			society_rank >= 3
			has_character_flag = guilds_show_decision
		}

		allow = {
			is_inaccessible_or_incapable_guilds_trigger = yes
		}

		effect = {
			character_event = { id = SNW.181 } 
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 0.5
			modifier = {
				factor = 2
				scaled_wealth = 1
				wealth = 50
			}
			modifier = {
				factor = 0
				has_artifact = guilds_item_shop_stall
				has_artifact = guilds_item_shop_caravan
			}
		}
	}
#Caravan options
	guilds_caravan_option = {
		# is_in_society = yes
		
		only_rulers = yes
		potential = {
			OR = {
				is_landed = yes
				is_patrician = yes
			}
			society_member_of = the_guilds
			society_rank >= 3
			has_character_flag = guilds_show_decision
		}

		allow = {
			is_inaccessible_or_incapable_guilds_trigger = yes
			has_artifact = guilds_item_shop_caravan
			custom_tooltip = {
				text = guilds_prepared_caravan_tooltip
				NOT = { has_character_flag = guilds_prepared_caravan }
				NOT = { has_character_flag = guilds_preparing_caravan }
			}
		}

		effect = {
			set_character_flag = guilds_preparing_caravan 
			character_event = { id = SNW.191 } 
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 0
		}
	}
#Clear debt
	guilds_clear_debt = {
		# is_in_society = yes
		ai_check_interval = 4
		only_rulers = yes
		potential = {
			OR = {
				is_landed = yes
				is_patrician = yes
			}
			society_member_of = the_guilds
			society_rank >= 3
			has_character_flag = guilds_show_decision
			NOT = { has_character_flag = guilds_cleared_debt }
		}

		allow = {
			society_currency = 500
			society_influence > 50
			NOT = { wealth = 0 }
			custom_tooltip = {
				NOT = { has_global_flag = guilds_market_crash_start }
				text = guilds_market_crash_start_tooltip
			}
		}

		effect = {
			change_society_currency = -500
			set_character_flag = guilds_cleared_debt 
			hidden_tooltip = {
				wealth = 10000
				remove_character_modifier = guilds_loan_one
				remove_character_modifier = guilds_loan_two
				remove_character_modifier = guilds_loan_three
			}
			clear_wealth = yes
			clear_delayed_event = { id = SNW.1501 }
			clear_delayed_event = { id = SNW.1511 }
			guilds_add_influence_debt = yes
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.5
				wealth >= -50
			}
			modifier = {
				factor = 0.75
				wealth <= -51
				wealth >= -100
			}
		}
	}
#Become republic
	guilds_become_republic = {
		# is_in_society = yes
		ai_check_interval = 12
		only_rulers = yes
		potential = {
			is_landed = yes
			society_member_of = the_guilds
			society_rank = 4
			OR = {
				AND = {
					higher_tier_than = count
					ai = no 
				}
				AND = {
					tier = duke
					stewardship = 15
					ai = yes 
				}
			}
			is_patrician = no
			has_character_flag = guilds_show_decision
		}

		allow = {
			war = no
			# is_female = no
			is_inaccessible_or_incapable_guilds_trigger = yes
			capital_holding = {
				OR = {
					holding_type = castle
					holding_type = temple
					holding_type = tribal
					holding_type = city
				}
			}
			capital_scope = {
				port = yes
			}
			has_dlc = "The Republic"
			scaled_wealth = { value = 2 min = 200 max = 2000 }
			has_society_currency_major_trigger = yes
		}

		effect = {
			set_character_flag = guilds_created_republic
			if = {
				limit = {
					independent = no
					liege = {
						NOR = {
							society_member_of = the_guilds
							is_patrician = yes
						}
					}
				}
				custom_tooltip = { text = guilds_liegewillbeangry_tooltip }
				liege = { character_event = { id = SNW.430 days = 15 } }
			}
			scaled_wealth = { value = -3 min = -300 max = -3000 }
			change_society_currency = -500
			hidden_tooltip = {
				create_family_palace = yes
				
				set_government_type = merchant_republic_government
				
				if = {
					limit = {
						NOT = {
							num_of_government_vassals = {
								government = merchant_republic_government
								value = 1
							}
						}
					}
					
					any_unique_dynasty_vassal = { # gives random vassals a family palace
						count = 4
						limit = {
							# OR = { #redundant
								# society_member_of = the_guilds
								# is_in_society = no
							# }
							# is_female = no
							OR = {
								is_republic = yes
								is_tribal = yes
								is_feudal = yes
							}
							is_patrician = no
							prisoner = no
							is_incapable = no
							is_adult = yes
							NOT = { 
								dynasty = none 
							}
						}
						if = {
							limit = { is_in_society = no }
							join_society = the_guilds
						}
						
						if = {
							limit = { is_tribal = yes }
							
							hidden_tooltip = {
								any_demesne_title = {
									limit = {
										tier = baron
										holding_type = tribal
									}
									convert_to = CITY
									refill_holding_levy = yes
									
									if = {
										limit = {
											dejure_liege_title = {
												holder = PREVPREV
												location = {
													num_of_empty_holdings = 2
												}
												NOT = {
													any_direct_de_jure_vassal_title = {
														holding_type = castle
													}
												}
											}
										}
										location = {
											build_holding = {
												type = castle
											}
										}
									}
									if = {
										limit = {
											dejure_liege_title = {
												holder = PREVPREV
												location = {
													num_of_empty_holdings = 2
												}
												NOT = {
													any_direct_de_jure_vassal_title = {
														holding_type = temple
													}
												}
											}
										}
										location = {
											build_holding = {
												type = temple
											}
										}
									}
								}
							}
						}
						
						create_family_palace = yes
					}
				}
				
				any_demesne_title = {
					limit = {
						tier = baron
						holding_type = tribal
					}
					convert_to = CITY
					refill_holding_levy = yes
					
					if = {
						limit = {
							dejure_liege_title = {
								holder = ROOT
								location = {
									num_of_empty_holdings = 2
								}
								NOT = {
									any_direct_de_jure_vassal_title = {
										holding_type = castle
									}
								}
							}
						}
						location = {
							build_holding = {
								type = castle
							}
						}
					}
					if = {
						limit = {
							dejure_liege_title = {
								holder = ROOT
								location = {
									num_of_empty_holdings = 2
								}
								NOT = {
									any_direct_de_jure_vassal_title = {
										holding_type = temple
									}
								}
							}
						}
						location = {
							build_holding ={
								type = temple
							}
						}
					}
				}
			}
			
			if = {
				limit = {
					ai = no
				}
				chronicle = {
					entry = CHRONICLE_FOUNDED_MERCHANT_REPUBLIC
					picture = GFX_evt_busy_trading_dock_republic
				}
			}
			
			set_government_type = merchant_republic_government
			if = {
				limit = {
					is_female = yes
					OR = {
						has_religion_feature = religion_matriarchal
						primary_title = { has_law = enatic_succession }
					}
				}
				primary_title = { add_law = enatic_succession }
			}
			else_if = {
				limit = {
					NOT = { has_religion_feature = religion_patriarchal }
					is_female = yes
					NOT = { religion_group = muslim }
					OR = {
						primary_title = { has_law = status_of_women_5 }
						any_owned_bloodline = {
							has_bloodline_flag = bloodline_enatic_cognatic 
						}
						has_game_rule = {
							name = gender
							value = all
						}
						primary_title = { has_law = enatic_cognatic_succession }
					}
				}
				primary_title = { add_law = enatic_cognatic_succession }
			}
			else_if = {
				limit = {
					NOT = { has_religion_feature = religion_patriarchal }
					OR = {
						is_female = yes
						primary_title = { has_law = status_of_women_4 }
						has_religion_feature = religion_equal
						has_religion_feature = religion_feature_bon
						has_game_rule = {
							name = gender
							value = all
						}
						primary_title = { has_law = true_cognatic_succession }
					}
				}
				primary_title = { add_law = true_cognatic_succession }
			}
			else_if = {
				limit = {
					NOT = { has_religion_feature = religion_patriarchal }
					OR = {
						primary_title = { has_law = status_of_women_3 }
						primary_title = { has_law = cognatic_succession }
					}
				}
				primary_title = { add_law = cognatic_succession }
			}
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				top_liege = { is_nomadic = yes }
			}
			modifier = {
				factor = 0.25
				top_liege = {
					capital_holding = {
						owner = { NOT = { character = ROOT } }
						OR = { 
							holding_type = castle
							holding_type = temple
							holding_type = tribal
						}
					}
					
				}
			}
		}
	}
#Delivery
	guilds_delivery_button = {
		# is_high_prio = yes
		
		only_rulers = yes
		potential = {
			society_member_of = the_guilds
			has_quest = quest_guilds_delivery
			has_character_flag = guilds_show_decision
		}
		allow = {
			is_inaccessible_or_incapable_guilds_trigger = yes
			NOT = { has_character_flag = guilds_delivering }
			#block_general_event_trigger = no
		}
		effect = {
			set_character_flag = guilds_delivering
			if = {
				limit = {
					ai = no
				}
				hidden_tooltip = { character_event = { id = SNW.332 } }
				hidden_tooltip = { character_event = { id = SNW.333 days = 1 } }
			}
			if = {
				limit = {
					ai = yes
				}
			hidden_tooltip = { character_event = { id = SNW.332 days = 200 } }
			hidden_tooltip = { character_event = { id = SNW.333 days = 201 } }
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1
		}
	}
#Craft
	guilds_craft_button = {
		is_high_prio = yes
		ai_check_interval = 4
		only_rulers = yes
		potential = {
			society_member_of = the_guilds
			society_rank >= 2
			is_inaccessible_or_incapable_guilds_trigger = yes
			has_character_flag = guilds_show_decision
		}
		allow = {
			is_inaccessible_or_incapable_guilds_trigger = yes
			society_currency >= 75
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				NOT = { has_character_flag = guilds_is_using_goods }
			}
			custom_tooltip = {
				text = guilds_can_craft_tooltip
				OR = {
					has_artifact = guilds_item_stone
					AND = {
						has_artifact = guilds_item_grain
						has_artifact = guilds_item_pottery
					}
					AND = {
						has_artifact = guilds_item_meat
						has_artifact = guilds_item_spices
					}
					any_artifact = {
						count = 4
						artifact_type = guilds_item_grain
					}
					any_artifact = {
						count = 2
						artifact_type = guilds_item_stone
					}
					AND = {
						has_artifact = guilds_item_hide
						has_artifact = guilds_item_lumber
					}
					AND = {
						has_artifact = guilds_item_stone
						has_artifact = guilds_item_lumber
						has_artifact = guilds_item_silver
					}
					AND = {
						has_artifact = guilds_item_gold
						has_artifact = guilds_item_gem
					}
					AND = {
						has_artifact = guilds_item_gold
						has_artifact = guilds_item_silver
						OR = {
							has_dlc = "Mystics"
							has_dlc = "Jade Dragon"
						}
					}
					AND = {
						has_artifact = guilds_item_gold
						has_artifact = guilds_item_jewelry
						OR = {
							has_dlc = "Mystics"
							has_dlc = "Jade Dragon"
						}
					}
					AND = {
						has_artifact = guilds_item_lumber
						has_artifact = guilds_item_grain
						has_artifact = guilds_item_meat
					}
					AND = {
						has_artifact = guilds_item_linen
						has_artifact = guilds_item_wool
						has_artifact = guilds_item_silk
					}
					AND = {
						has_artifact = guilds_item_hide
						has_artifact = guilds_item_lumber
					}
					AND = {
						has_artifact = guilds_item_steel
						has_artifact = guilds_item_hide
						OR = {
							has_dlc = "Mystics"
							has_dlc = "Jade Dragon"
						}
					}
					AND = {
						has_artifact = guilds_item_steel
						has_artifact = guilds_item_lumber
						OR = {
							has_dlc = "Mystics"
							has_dlc = "Jade Dragon"
						}
					}
					AND = {
						has_artifact = guilds_item_steel
						has_artifact = guilds_item_gem
						OR = {
							has_dlc = "Mystics"
							has_dlc = "Jade Dragon"
						}
					}
					AND = {
						has_artifact = guilds_item_hide
						has_artifact = guilds_item_hide
					}
				}
			}
		}
		effect = {
			character_event = { id = SNW.270 }
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.5
				artifact_type = guilds_item_stone
			}
		}
	}
#Create center of trade
	guilds_create_center = {
		ai_check_interval = 4
		only_rulers = yes
		potential = {
			is_landed = yes
			society_member_of = the_guilds
			society_rank = 4
			has_character_flag = guilds_show_decision
			NOT = { has_character_flag = guilds_created_center }
		}

		allow = {
			is_inaccessible_or_incapable_guilds_trigger = yes
			capital_holding = {
				OR = {
					holding_type = castle
					holding_type = temple
					holding_type = tribal
					holding_type = city
				}
			}
			any_demesne_province  = {
				any_province_holding = { 
					owner = { character = ROOT }
					NOR = {
						has_holding_modifier = guilds_center_trade
						has_holding_modifier = guilds_center_trade_sieged
					}
				}
			}
			scaled_wealth = { value = 2 min = 200 max = 2000 }
			society_currency >= 500
		}

		effect = {
			scaled_wealth = { value = -2 min = -200 max = -2000 }
			change_society_currency = -500
			set_character_flag = guilds_created_center
			character_event = { id = SNW.340 }
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOT = { scaled_wealth = 2 }
			}
		}
	}
	guilds_repair_center = {

		is_high_prio = yes
		only_rulers = yes
		
		potential = {
			is_landed = yes
			society_member_of = the_guilds
			has_character_flag = guilds_show_decision
				any_demesne_province  = {
					any_province_holding = {
						owner = { character = ROOT }
						has_holding_modifier = guilds_center_trade_sieged
					}
				}
		}

		allow = {
			is_inaccessible_or_incapable_guilds_trigger = yes
			capital_holding = {
				OR = {
					holding_type = castle
					holding_type = temple
					holding_type = tribal
					holding_type = city
				}
				is_occupied = no
			}
			any_demesne_province  = {
				any_province_holding = {
					owner = { character = ROOT }
					has_holding_modifier = guilds_center_trade_sieged
				}
			}
			society_currency >= 250
		}

		effect = {
			scaled_wealth = -1
			change_society_currency = -250
			capital_holding = {
				add_holding_modifier = {
					name = guilds_center_trade
					duration = -1
				}
			}
			hidden_tooltip = {
				any_demesne_province  = {
					any_province_holding = { 
						limit = { owner = { character = ROOT } }
						remove_holding_modifier = guilds_center_trade_sieged 
					}
				}
			}
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOT = { scaled_wealth = 1.5 }
			}
		}
	}
#Society mapmode
	guilds_society_mapmode_buy = { #disabled

		only_rulers = yes
		ai = no 
		potential = {
			always = no
			society_member_of = the_guilds
			is_inaccessible_or_incapable_guilds_trigger = yes
			has_character_flag = guilds_show_decision
			NOT = { has_character_modifier = guilds_bought_mapmode }
			multiplayer = no
		}

		allow = {
			society_currency >= 100
			scaled_wealth = { value = 0.5 min = 50 max = 500 }
			NOT = { has_character_flag = guilds_mapmode }
		}

		effect = {
			scaled_wealth = { value = -0.5 min = -50 max = -500 }
			change_society_currency = -100
			hidden_tooltip = {
				add_character_modifier = {
					name = guilds_bought_mapmode
					years = 2
					hidden = yes
				}
				set_character_flag = guilds_mapmode
			}
			hidden_tooltip = {
				# any_province  = { #save for thief
					# limit = { 
						# any_province_lord = {
							# primary_title = { higher_tier_than = DUKE } 
							# has_assigned_minor_title = title_guilds_master 
						# } 
					# }
					# owner = {
						# capital_scope = {
							# add_province_modifier = {
								# name = guilds_mapmode_yes
								# duration = -1
								# hidden = yes
							# }
						# }
					# }
				# }
				# any_province  = {
					# limit = { 
						# any_province_lord = {
							# society_member_of = the_guilds
						# }
					# }
					# add_province_modifier = {
						# name = guilds_mapmode_yes
						# duration = -1
						# hidden = yes
					# }
				# }
				# any_province  = {
					# limit = { 
						# any_province_lord = {
							# NOT = { society_member_of = the_guilds }
						# }
					# }
					# add_province_modifier = {
						# name = guilds_mapmode_no
						# duration = -1
						# hidden = yes
					# }
				# }
				any_province  = {
					limit = { 
						has_guilds_shipment = yes
					}
					add_province_modifier = {
						name = guilds_mapmode_yes
						duration = -1
						hidden = yes
					}
				}
				any_province  = {
					limit = { 
						has_guilds_shipment = no
					}
					add_province_modifier = {
						name = guilds_mapmode_no
						duration = -1
						hidden = yes
					}
				}
			}
			hidden_tooltip = {
				change_variable = { which = guildsxp value = 1 }
			}
			letter_event = { id = SNW.370 }
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 0
		}
	}
	guilds_society_mapmode_look = { #disabled

		only_rulers = yes
		ai = no 
		potential = {
			always = no
			society_member_of = the_guilds
			is_inaccessible_or_incapable_guilds_trigger = yes
			has_character_flag = guilds_show_decision
			has_character_modifier = guilds_bought_mapmode
			multiplayer = no
		}

		allow = {
			NOT = { has_character_flag = guilds_mapmode }
		}

		effect = {
			hidden_tooltip = {
				set_character_flag = guilds_mapmode
			}
			hidden_tooltip = {
				# any_province  = {
					# limit = { 
						# any_province_lord = {
							# primary_title = { higher_tier_than = DUKE } 
						# } 
					# }
					# owner = {
						# capital_scope = {
							# add_province_modifier = {
								# name = guilds_mapmode_yes
								# duration = -1
								# hidden = yes
							# }
						# }
					# }
				# }
				# any_province  = {
					# limit = { 
						# any_province_lord = {
							# society_member_of = the_guilds
						# }
					# }
					# add_province_modifier = {
						# name = guilds_mapmode_yes
						# duration = -1
						# hidden = yes
					# }
				# }
				# any_province  = {
					# limit = { 
						# any_province_lord = {
							# NOT = { society_member_of = the_guilds }
						# }
					# }
					# add_province_modifier = {
						# name = guilds_mapmode_no
						# duration = -1
						# hidden = yes
					# }
				# }
				any_province  = {
					limit = { 
						has_guilds_shipment = yes
					}
					add_province_modifier = {
						name = guilds_mapmode_yes
						duration = -1
						hidden = yes
					}
				}
				any_province  = {
					limit = { 
						has_guilds_shipment = no
					}
					add_province_modifier = {
						name = guilds_mapmode_no
						duration = -1
						hidden = yes
					}
				}
				# any_province  = {
					# limit = { 
						# has_province_modifier = guilds_shop_caravan
					# }
					# add_province_modifier = {
						# name = guilds_mapmode_caravan
						# duration = -1
						# hidden = yes
					# }
				# }
			}
			letter_event = { id = SNW.370 }
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 0
		}
	}
#Build a warehouse
	#Show warehouse decisions
	guilds_show_warehouse_on = {
		# is_in_society = yes
		
		only_rulers = yes
		potential = {
			OR = {
				is_landed = yes
				is_patrician = yes
			}
			has_any_warehouse = yes
			society_member_of = the_guilds
			society_rank >= 1
			has_character_flag = guilds_show_decision
			NOT = { has_character_flag = guilds_show_warehouse }
		}

		allow = {
		}

		effect = {
			set_character_flag = guilds_show_warehouse
			sound_effect = turning_page
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 1
		}
	}
	guilds_show_warehouse_off = {
		# is_in_society = yes
		
		only_rulers = yes
		potential = {
			OR = {
				is_landed = yes
				is_patrician = yes
			}
			has_any_warehouse = yes
			society_member_of = the_guilds
			society_rank >= 1
			has_character_flag = guilds_show_decision
			has_character_flag = guilds_show_warehouse
		}

		allow = {
		}

		effect = {
			clr_character_flag = guilds_show_warehouse
			sound_effect = letter_event
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 0
		}
	}
	guilds_build_warehouse_button = {
		# is_high_prio = yes 
		ai_check_interval = 24
		only_rulers = yes
		potential = {
			society_member_of = the_guilds
			# has_quest = quest_guilds_build_warehouse
			NOT = { has_character_flag = guilds_building_warehouse }
			has_character_flag = guilds_show_decision
			# has_character_flag = guilds_show_warehouse
			# NOR = {
				# has_artifact = guilds_warehouse_gold
				# has_artifact = guilds_warehouse_custom
				# has_artifact = guilds_warehouse_incense
				# has_artifact = guilds_warehouse_book
				# has_artifact = guilds_warehouse_silk
			# }
			has_no_warehouse = yes
		}
		allow = {
			wealth = 50
			OR = {
				has_quest = quest_guilds_build_warehouse
				society_currency = 100
			}
		}
		effect = {
			wealth = -50
			if = {
				limit = {
					NOT = { has_quest = quest_guilds_build_warehouse }
				}
				change_society_currency = -100
			}
			set_character_flag = guilds_building_warehouse
			custom_tooltip = { text = guilds_building_warehouse_tooltip }
			hidden_tooltip = { character_event = { id = SNW.322 } }
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0.5
			
			modifier = {
				factor = 0
				NOT = { wealth = 100 }
			}
		}
	}
	guilds_decorated_warehouse_guilds = {
		ai_check_interval = 12
		only_rulers = yes
		potential = {
			NOT = { has_artifact = guilds_warehouse_guilds }
			society_member_of = the_guilds
			#block_general_event_trigger = no
			# NOT = { has_character_flag = guilds_building_warehouse }
			has_character_flag = guilds_show_decision
			has_character_flag = guilds_show_warehouse
		}
		allow = {
			society_currency = 500
		}
		effect = {
			add_artifact = guilds_warehouse_guilds
			change_society_currency = -500
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0.5
		}
	}
	guilds_decorated_warehouse_gold = {
		ai_check_interval = 36
		only_rulers = yes
		potential = {
			has_artifact = guilds_warehouse_gold
			society_member_of = the_guilds
			NOT = { has_character_flag = guilds_building_warehouse }
			has_character_flag = guilds_show_decision
			has_character_flag = guilds_show_warehouse
		}
		allow = {
		}
		effect = {
			add_artifact = guilds_item_gold
			destroy_artifact = guilds_warehouse_gold
			# hidden_tooltip = { character_event = { id = SNW.325 } }
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0.2
		}
	}
	guilds_decorated_warehouse_incense = {
		ai_check_interval = 36
		only_rulers = yes
		potential = {
			has_artifact = guilds_warehouse_incense
			society_member_of = the_guilds
			NOT = { has_character_flag = guilds_building_warehouse }
			has_character_flag = guilds_show_decision
			has_character_flag = guilds_show_warehouse
		}
		allow = {
		}
		effect = {
			add_artifact = guilds_item_incense
			destroy_artifact = guilds_warehouse_incense
			# hidden_tooltip = { character_event = { id = SNW.325 } }
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0.2
		}
	}
	guilds_decorated_warehouse_silk = {
		ai_check_interval = 36
		only_rulers = yes
		potential = {
			has_artifact = guilds_warehouse_silk
			society_member_of = the_guilds
			#block_general_event_trigger = no
			NOT = { has_character_flag = guilds_building_warehouse }
			has_character_flag = guilds_show_decision
			has_character_flag = guilds_show_warehouse
		}
		allow = {
		}
		effect = {
			add_artifact = guilds_item_silk
			destroy_artifact = guilds_warehouse_silk
			# hidden_tooltip = { character_event = { id = SNW.325 } }
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0.2
		}
	}
	guilds_decorated_warehouse_book = {
		ai_check_interval = 36
		only_rulers = yes
		potential = {
			has_artifact = guilds_warehouse_book
			society_member_of = the_guilds
			#block_general_event_trigger = no
			NOT = { has_character_flag = guilds_building_warehouse }
			has_character_flag = guilds_show_decision
			has_character_flag = guilds_show_warehouse
		}
		allow = {
		}
		effect = {
			add_artifact = guilds_item_book
			destroy_artifact = guilds_warehouse_book
			# hidden_tooltip = { character_event = { id = SNW.325 } }
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0.2
		}
	}
	guilds_decorated_warehouse_custom = {
		ai_check_interval = 12
		only_rulers = yes
		potential = {
			has_any_warehouse = yes
			# OR = {
				# has_artifact = guilds_warehouse_gold
				# has_artifact = guilds_warehouse_incense
				# has_artifact = guilds_warehouse_silk
				# has_artifact = guilds_warehouse_book
			# }
			society_member_of = the_guilds
			#block_general_event_trigger = no
			NOT = { has_character_flag = guilds_building_warehouse }
			has_character_flag = guilds_show_decision
			has_character_flag = guilds_show_warehouse
		}
		allow = {
			OR = {
				AND = {
					has_artifact = guilds_item_gold
					NOT = { has_artifact = guilds_warehouse_gold }
				}
				AND = {
					has_artifact = guilds_item_incense
					NOT = { has_artifact = guilds_warehouse_incense }
				}
				AND = {
					has_artifact = guilds_item_silk
					NOT = { has_artifact = guilds_warehouse_silk }
				}
				AND = {
					has_artifact = guilds_item_book
					NOT = { has_artifact = guilds_warehouse_book }
				}
			}
			hidden_tooltip = {
				OR = {
					ai = no
					NOR = {
						has_artifact = guilds_warehouse_gold
						has_artifact = guilds_warehouse_incense
						has_artifact = guilds_warehouse_silk
						has_artifact = guilds_warehouse_book
					}
				}
			}
		}
		effect = {
			hidden_tooltip = { character_event = { id = SNW.325 } }
			# destroy_artifact = guilds_warehouse_custom
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0.5
		}
	}
	guilds_sell_warehouse = {
		ai_check_interval = 12
		only_rulers = yes
		potential = {
			ai = yes
			OR = {
				has_artifact = guilds_warehouse_gold
				has_artifact = guilds_warehouse_incense
				has_artifact = guilds_warehouse_silk
				has_artifact = guilds_warehouse_book
			}
			society_member_of = the_guilds
			NOT = { has_character_flag = guilds_building_warehouse }
			has_character_flag = guilds_show_decision
			has_character_flag = guilds_show_warehouse
		}
		allow = {
			OR = {
				has_artifact = guilds_warehouse_gold
				has_artifact = guilds_warehouse_incense
				has_artifact = guilds_warehouse_silk
				has_artifact = guilds_warehouse_book
			}
		}
		effect = {
			hidden_tooltip = { character_event = { id = SNW.326 } }
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = { 
			factor = 1
			
			modifier = {
				factor = 0
				wealth = -200
			}
		}
	}
	#Guards
	# guilds_guarding_warehouse_on = {
		# is_in_society = yes
		
		# only_rulers = yes
		# potential = {
			# OR = {
				# is_landed = yes
				# is_patrician = yes
			# }
			# any_artifact = { has_artifact_flag = warehouse }
			# society_member_of = the_guilds
			# has_character_flag = guilds_show_decision
			# has_character_flag = guilds_show_warehouse
			# NOT = { has_artifact = guilds_warehouse_guard }
		# }

		# allow = {
		# }

		# effect = {
			# add_artifact = guilds_warehouse_guard
		# }

		# revoke_allowed = { always = no }

		# ai_will_do = {
			# factor = 0.1
			# modifier = {
				# factor = 0
				# NOT = { wealth = 0 }
			# }
			# modifier = {
				# factor = 0
				# NOT = { yearly_income = 50 }
			# }
			# modifier = {
				# factor = 10
				# any_artifact = {
					# count = 3
					# has_artifact_flag = goods
				# }
			# }
		# }
	# }
	guilds_discard_warehouse = {
		ai_check_interval = 24
		only_rulers = yes
		ai = no
		potential = {
			capital_holding = {
				OR = {
					has_building = guilds_warehouse_1_city
					has_building = guilds_warehouse_1_castle
					has_building = guilds_warehouse_1_temple
					has_building = guilds_warehouse_1_tribal
					has_building = guilds_warehouse_1_nomad
				}
				NOR = {
					has_building = guilds_warehouse_2_city
					has_building = guilds_warehouse_2_castle
					has_building = guilds_warehouse_2_temple
					has_building = guilds_warehouse_2_tribal
					has_building = guilds_warehouse_2_nomad
					has_building = guilds_warehouse_3_city
					has_building = guilds_warehouse_3_castle
					has_building = guilds_warehouse_3_temple
					has_building = guilds_warehouse_3_tribal
					has_building = guilds_warehouse_3_nomad
				}
			}
			society_member_of = the_guilds
			NOT = { has_character_flag = guilds_building_warehouse }
			has_character_flag = guilds_show_decision
			has_character_flag = guilds_show_warehouse
		}
		allow = {
		}
		effect = {
			capital_holding = {
				trigger_switch = {
					on_trigger = holding_type
					city = { remove_building = guilds_warehouse_1_city }
					castle = { remove_building = guilds_warehouse_1_castle }
					temple = { remove_building = guilds_warehouse_1_temple }
					tribal = { remove_building = guilds_warehouse_1_tribal }
					nomad = { remove_building = guilds_warehouse_1_nomad }
				}
				# remove_building = guilds_warehouse_1_city
				# remove_building = guilds_warehouse_1_castle
				# remove_building = guilds_warehouse_1_temple
				# remove_building = guilds_warehouse_1_tribal
				# remove_building = guilds_warehouse_1_nomad
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0
		}
	}
	guilds_guarding_warehouse_off = {
		# is_in_society = yes
		ai_check_interval = 24
		only_rulers = yes
		potential = {
			has_safe_warehouse = yes
			# has_artifact = guilds_warehouse_guard
			# OR = {
				is_landed = yes
				# is_patrician = yes
			# }
			# any_artifact = { has_artifact_flag = warehouse }
			society_member_of = the_guilds
			has_character_flag = guilds_show_decision
			has_character_flag = guilds_show_warehouse
		}

		allow = {
		}

		effect = {
			# destroy_artifact = guilds_warehouse_guard
			capital_holding = {
				remove_building = guilds_warehouse_3_city
				remove_building = guilds_warehouse_3_castle
				remove_building = guilds_warehouse_3_temple
				remove_building = guilds_warehouse_3_tribal
				remove_building = guilds_warehouse_3_nomad
			}
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 0.1
			modifier = {
				factor = 10
				NOT = { wealth = 0 }
			}
		}
	}
#Greatest trader bloodline
	guilds_get_bloodline = {
		# is_in_society = yes
		ai_check_interval = 24
		only_rulers = yes
		is_high_prio = yes
		potential = {
			OR = {
				is_landed = yes
				is_patrician = yes
			}
			society_member_of = the_guilds
			society_rank == 4
			has_character_flag = guilds_show_decision
			NOT = {
				any_owned_bloodline = {
					has_bloodline_flag = the_guilds
				}
			}
		}

		allow = {
			society_rank == 4
			trait = guilds_trait_master
			scaled_wealth = { value = 3 min = 300 max = 3000 }
			society_currency = 500
			custom_tooltip = {
				capital_holding = {
					OR = {
						has_building = guilds_warehouse_3_city
						has_building = guilds_warehouse_3_castle
						has_building = guilds_warehouse_3_temple
						has_building = guilds_warehouse_3_tribal
						has_building = guilds_warehouse_3_nomad
					}
				}
				OR = {
					has_artifact = guilds_warehouse_gold
					has_artifact = guilds_warehouse_incense
					has_artifact = guilds_warehouse_silk
					has_artifact = guilds_warehouse_book
				}
				has_artifact = guilds_warehouse_guilds
				text = guilds_warehouse_3_decorated
			}
			custom_tooltip = {
				OR = {
					has_game_rule = { #maybe better
						name = guilds_rule_resource
						value = none
					}
					has_character_flag = guilds_got_resources_flag
				}
				text = guilds_got_resources_flag_tooltip
			}
			custom_tooltip = {
				has_character_flag = guilds_created_center
				text = guilds_created_center_tooltip
			}
			OR = {
				custom_tooltip = {
					has_character_flag = guilds_created_republic
					text = guilds_created_republic_tooltip
				}
				custom_tooltip = {
					has_character_flag = guilds_market_crash_won_flag
					text = guilds_market_crash_won_tooltip
				}
				custom_tooltip = {
					check_variable = { which = guildsxp value >= 100 }
					text = guilds_blood_xp_tooltip
				}
			}
		}

		effect = {
			change_society_currency = -500
			sound_effect = bloodline_added
			create_bloodline = {
				type = guilds_bloodline
			}
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 1
		}
	}
}

#non-members stuff
decisions = {
	guilds_bribe_leaders = {
		only_playable = yes
		AI = no
		potential = { 
			has_character_flag = guilds_traitor
		}
		allow = {
		}
		effect = {
			character_event = { id = SNW.450 }
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0
		}
	}
	#resources
	guilds_start_resource = {
		ai_check_interval = 30
		only_playable = yes
		potential = {
			has_game_rule = {
				name = guilds_rule_resource
				value = default
			}
			is_landed = yes
			primary_title = { higher_tier_than = BARON } 
		}
		allow = {
			custom_tooltip = {
				text = guilds_demesne_province_no_resources_tt
				any_demesne_province = {
					capital_holding = { 
						OR = {
							holding_type = tribal
							holding_type = temple
							holding_type = castle
							holding_type = city
							holding_type = nomad
						}
					}
					NOR = {
						has_province_modifier = guilds_res_stone
						has_province_modifier = guilds_res_steel
						has_province_modifier = guilds_res_gem
						has_province_modifier = guilds_res_silver
						has_province_modifier = guilds_res_gold
						has_province_modifier = guilds_res_grain
						has_province_modifier = guilds_res_lumber
						has_province_modifier = guilds_res_linen
						has_province_modifier = guilds_res_incense
						has_province_modifier = guilds_res_spices
						has_province_modifier = guilds_res_meat
						has_province_modifier = guilds_res_wool
						has_province_modifier = guilds_res_hide
						has_province_modifier = guilds_res_ivory
						has_province_modifier = guilds_res_silk
					}
				}
			}
			custom_tooltip = {
				text = guilds_cooldown_resources_tt
				NOT = { has_character_modifier = guilds_resources_timer }
				NOT = { has_character_flag = guilds_resource_flag_herd }
				NAND = {
					ai = yes
					war = yes
				}
			}
		}
		effect = {
			hidden_tooltip = { 
				character_event = { id = SNW.393 }
				# add_character_modifier = {
					# name = guilds_resources_timer
					# duration = -1
					# hidden = yes
				# }
				set_character_flag = guilds_resource_flag_herd
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0.3
		}
	}
	# Discard old warehouse 
	guilds_discard_warehouse_outsider = {
		ai_check_interval = 36
		only_rulers = yes
		potential = {
			capital_holding = {
				OR = {
					has_building = guilds_warehouse_1_city
					has_building = guilds_warehouse_1_castle
					has_building = guilds_warehouse_1_temple
					has_building = guilds_warehouse_1_tribal
					has_building = guilds_warehouse_1_nomad
				}
				NOR = {
					has_building = guilds_warehouse_2_city
					has_building = guilds_warehouse_2_castle
					has_building = guilds_warehouse_2_temple
					has_building = guilds_warehouse_2_tribal
					has_building = guilds_warehouse_2_nomad
					has_building = guilds_warehouse_3_city
					has_building = guilds_warehouse_3_castle
					has_building = guilds_warehouse_3_temple
					has_building = guilds_warehouse_3_tribal
					has_building = guilds_warehouse_3_nomad
				}
			}
			NOT = { society_member_of = the_guilds }
		}
		allow = {
		}
		effect = {
			capital_holding = {
				trigger_switch = {
					on_trigger = holding_type
					city = { remove_building = guilds_warehouse_1_city }
					castle = { remove_building = guilds_warehouse_1_castle }
					temple = { remove_building = guilds_warehouse_1_temple }
					tribal = { remove_building = guilds_warehouse_1_tribal }
					nomad = { remove_building = guilds_warehouse_1_nomad }
				}
				# remove_building = guilds_warehouse_1_city
				# remove_building = guilds_warehouse_1_castle
				# remove_building = guilds_warehouse_1_temple
				# remove_building = guilds_warehouse_1_tribal
				# remove_building = guilds_warehouse_1_nomad
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1
		}
	}
	#Sell old warehouse
	guilds_sell_warehouse_outsider = {
		ai_check_interval = 24
		only_rulers = yes
		potential = {
			OR = {
				has_artifact = guilds_warehouse_gold
				has_artifact = guilds_warehouse_incense
				has_artifact = guilds_warehouse_silk
				has_artifact = guilds_warehouse_book
				has_artifact = guilds_warehouse_guilds
			}
			NOT = { society_member_of = the_guilds }
			#block_general_event_trigger = no
		}
		allow = {
			OR = {
				has_artifact = guilds_warehouse_gold
				has_artifact = guilds_warehouse_incense
				has_artifact = guilds_warehouse_silk
				has_artifact = guilds_warehouse_book
				has_artifact = guilds_warehouse_guilds
			}
		}
		effect = {
			hidden_tooltip = { character_event = { id = SNW.326 } }
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0.5
		}
	}
	#Guards
	# guilds_guarding_warehouse_out_on = {
		
		# only_rulers = yes
		# potential = {
			# OR = {
				# is_landed = yes
				# is_patrician = yes
			# }
			# any_artifact = { has_artifact_flag = warehouse }
			# NOT = { society_member_of = the_guilds }
			# NOT = { has_artifact = guilds_warehouse_guard }
		# }

		# allow = {
		# }

		# effect = {
			# add_artifact = guilds_warehouse_guard
		# }

		# revoke_allowed = { always = no }

		# ai_will_do = {
			# factor = 0.1
			# modifier = {
				# factor = 0
				# NOT = { wealth = 0 }
			# }
			# modifier = {
				# factor = 0
				# NOT = { yearly_income = 50 }
			# }
			# modifier = {
				# factor = 10
				# any_artifact = {
					# count = 3
					# has_artifact_flag = goods
				# }
			# }
		# }
	# }
	guilds_guarding_warehouse_out_off = {
		# is_in_society = yes
		ai_check_interval = 24
		only_rulers = yes
		potential = {
			# has_artifact = guilds_warehouse_guard
			has_safe_warehouse = yes
			# OR = {
				is_landed = yes
				# is_patrician = yes
			# }
			# any_artifact = { has_artifact_flag = warehouse }
			NOT = { society_member_of = the_guilds }
		}

		allow = {
		}

		effect = {
			capital_holding = {
				remove_building = guilds_warehouse_3_city
				remove_building = guilds_warehouse_3_castle
				remove_building = guilds_warehouse_3_temple
				remove_building = guilds_warehouse_3_tribal
				remove_building = guilds_warehouse_3_nomad
			}
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 0.1
			modifier = {
				factor = 10
				NOT = { wealth = 0 }
			}
		}
	}

	#Force AI to set trade master
	guilds_AI_set_trade_master = {
		ai_check_interval = 12
		potential = {
			has_game_rule = {
				name = guilds_rule_master
				value = default
			}
			# has_global_flag = guilds_enabled_trade_master
			is_landed = yes
			primary_title = { higher_tier_than = DUKE } 
			NOT = { primary_title = { temporary = yes } }
			NOT = { society_member_of = the_guilds }
			ai = yes
		}
		allow = {
			NOT = { has_assigned_minor_title = title_guilds_master }
			any_courtier = {
				OR = {
					gender_equality_trigger = yes
					NOT = { is_female = yes	}
				}
				OR = {
					trait = indulgent_wastrel
					trait = thrifty_clerk
					trait = fortune_builder
					trait = midas_touched
					trait = vaishya
				}
				OR = {
					society_member_of = the_guilds
					is_in_society = no
				}
				is_ruler = no
				NOT = { trait = in_hiding }
				is_inaccessible_or_incapable_guilds_trigger = yes
				has_job_title = no
				opinion = { who = liege value = 10 }
			}
		}
		
		effect = {
			random_courtier = {
				limit = {
					OR = {
						gender_equality_trigger = yes
						NOT = { is_female = yes	}
					}
					OR = {
						trait = indulgent_wastrel
						trait = thrifty_clerk
						trait = fortune_builder
						trait = midas_touched
						trait = vaishya
					}
					age = 16
					OR = {
						society_member_of = the_guilds
						is_in_society = no
					}
					is_ruler = no
					NOT = { trait = in_hiding }
					is_incapable = no
					prisoner = no
					has_job_title = no
					opinion = { who = liege value = 10 }
				} 
				give_minor_title = title_guilds_master
				if = {
					limit = { NOT = { society_member_of = the_guilds } }
					join_society = the_guilds
				}
				if = { #so they cannot spam give/remove the title to spam more quests
					limit = { NOT = { has_character_flag = guilds_trade_master_flag } }
					character_event = { id = SNW.260 days = 10 }  #Start AI chains
					set_character_flag = guilds_trade_master_flag
				}
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0.2
			modifier = {
				factor = 0
				is_nomadic = yes
			}
		}
	}
}

#non-members stuff, trade master
targetted_decisions = {
	guilds_buy_goods = {
		filter = all
		ai_target_filter = realm
		third_party_filter = artifacts
		ai_third_party_filter = artifacts
		third_party = ROOT
		ai_check_interval = 24
		show_third_party_potential = no
		only_playable = yes
		
		from_potential = {
			OR = {
				society_member_of = the_guilds
				AND = {
					ai = no
					any_owned_bloodline = {
						has_bloodline_flag = the_guilds
					}
				}
			}
		}
		potential = {
			NOT = { character = FROM }
			any_artifact = {
				has_artifact_flag = goods 
			}
		}
		third_party_potential = {
			# show_only_failed_conditions = yes
			FROMFROM = {
				has_artifact_flag = goods
			}
		}
		allow = {
			is_inaccessible_or_incapable_guilds_trigger = yes
			FROM = { is_inaccessible_or_incapable_guilds_trigger = yes }
			# FROM = { society_currency = 100 }
			FROM = { influence_cost_buying_trigger = yes }
			is_within_diplo_range = FROM
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
				ROOT = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_buy_timer_tooltip
				NOT = { has_character_modifier = guilds_buy_timer }
			}
		}
		effect = {
			# FROM = { change_society_currency = -50 }
			FROM = { influence_cost_buying_effect = yes }
			FROM = { character_event = { id = SNW.440 } }
			set_character_flag = guilds_is_using_goods
			FROM = { set_character_flag = guilds_is_using_goods }
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.5
				NOT = { scaled_wealth = 0.75 }
			}
			modifier = {
				factor = 0 
				NOT = { wealth = 50 }
			}
		}
	}
	guilds_trader_master_invest = {
		filter = home_court
		ai_target_filter = home_court
		ai = no 
		
		from_potential = {
			NOT = { society_member_of = the_guilds }
			OR = {
				ai = no
				primary_title = { higher_tier_than = DUKE } 
				any_courtier = { has_minor_title = title_guilds_master }
			}
		}
		potential = {
			has_minor_title = title_guilds_master
			NOT = { has_character_flag = guilds_trader_master_invest_focus }
		}
		allow = {
			has_minor_title = title_guilds_master
			NOT = { has_character_flag = guilds_trader_master_invest_focus }
		}
		effect = {
			set_character_flag = guilds_trader_master_invest_focus
			clr_character_flag = guilds_trader_master_profit_focus
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0
		}
	}
	guilds_trader_master_profit = {
		filter = home_court
		ai_target_filter = home_court
		ai = no
		
		from_potential = {
			NOT = { society_member_of = the_guilds }
			OR = {
				ai = no
				primary_title = { higher_tier_than = DUKE } 
				any_courtier = { has_minor_title = title_guilds_master }
			}
		}
		potential = {
			has_minor_title = title_guilds_master
			NOT = { has_character_flag = guilds_trader_master_profit_focus }
		}
		allow = {
			has_minor_title = title_guilds_master
			NOT = { has_character_flag = guilds_trader_master_profit_focus }
		}
		effect = {
			set_character_flag = guilds_trader_master_profit_focus
			clr_character_flag = guilds_trader_master_invest_focus
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0
		}
	}
	guilds_trader_master_balance = {
		filter = home_court
		ai_target_filter = home_court
		ai = no
		
		from_potential = {
			NOT = { society_member_of = the_guilds }
			OR = {
				ai = no
				primary_title = { higher_tier_than = DUKE } 
				any_courtier = { has_minor_title = title_guilds_master }
			}
		}
		potential = {
			has_minor_title = title_guilds_master
			OR = { 
				has_character_flag = guilds_trader_master_invest_focus
				has_character_flag = guilds_trader_master_profit_focus
			}
		}
		allow = {
			has_minor_title = title_guilds_master
			OR = { 
				has_character_flag = guilds_trader_master_invest_focus
				has_character_flag = guilds_trader_master_profit_focus
			}
		}
		effect = {
			clr_character_flag = guilds_trader_master_invest_focus
			clr_character_flag = guilds_trader_master_profit_focus
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0
		}
	}
	guilds_trader_master_cash = {
		filter = home_court
		ai_target_filter = home_court
		only_playable = yes
		
		from_potential = {
			NOT = { society_member_of = the_guilds }
			OR = {
				ai = no
				primary_title = { higher_tier_than = DUKE } 
				any_courtier = { has_minor_title = title_guilds_master }
			}
		}
		potential = {
			has_minor_title = title_guilds_master
			# wealth = 100
		}
		allow = {
			has_minor_title = title_guilds_master
			wealth = 100
		}
		effect = {
			if = {
				limit = {
					NOT = { opinion = { who = liege value = 0 } }
				}
				custom_tooltip = { text = guilds_unhappy_trade_master }
			}
			wealth = -100
			liege = { wealth = 100 }
			opinion = {
				modifier = opinion_disappointed
				who = FROM
				years = 1
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0.1
			modifier = {
				factor = 5
				war = yes
				NOT = { wealth = 50 }
			}
			modifier = {
				factor = 5
				NOT = { wealth = 0 }
			}
			modifier = {
				factor = 0.5
				ROOT = { NOT = { opinion = { who = liege value = 0 } } }
			}
		}
	}
	guilds_trader_master_give = {
		filter = home_court
		ai_target_filter = home_court
		only_playable = yes
		ai_check_interval = 12
		from_potential = {
			NOT = { society_member_of = the_guilds }
			OR = {
				ai = no
				primary_title = { higher_tier_than = DUKE } 
				any_courtier = { has_minor_title = title_guilds_master }
			}
		}
		potential = {
			has_minor_title = title_guilds_master
			# wealth = 100
		}
		allow = {
			has_minor_title = title_guilds_master
			FROM = { any_artifact = { has_artifact_flag = goods } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
		}
		effect = {
			FROM = {
				any_artifact = {
					limit = {
						has_artifact_flag = goods 
					}
					transfer_artifact = {
						from = FROM
						to = ROOT
					}
				}
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1
		}
	}
	guilds_trader_master_stop = {
		filter = home_court
		ai_target_filter = home_court
		ai = no
		ai_check_interval = 12
		from_potential = {
			NOT = { society_member_of = the_guilds }
			OR = {
				ai = no
				primary_title = { higher_tier_than = DUKE } 
				any_courtier = { has_minor_title = title_guilds_master }
			}
		}
		potential = {
			has_minor_title = title_guilds_master
		}
		allow = {
			has_minor_title = title_guilds_master
		}
		effect = {
			if = {
				limit = {
					has_character_flag = guilds_trade_master_stop
				}
				clr_character_flag = guilds_trade_master_stop
			}
			else = {
				set_character_flag = guilds_trade_master_stop
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0
		}
	}
	guilds_wed_holo = {
		filter = home_court
		ai_target_filter = self
		only_playable = yes
		
		from_potential = {
			ai = no
			is_married = no
			prisoner = no
			has_character_flag = guilds_met_holo
		}
		potential = {
			has_character_flag = guilds_is_holo
			has_character_flag = guilds_holo_lover
			is_married = no
		}
		allow = {
			is_married = no
			FROM = { is_married = no }
		}
		effect = {
			remove_trait = nun
			remove_trait = celibate
			add_trait = hedonist
			add_spouse = FROM
			FROM = { set_character_flag = guilds_holo_family }
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0
		}
	}	
}

#Buffs
settlement_decisions = {
	guilds_buffing_stone = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 12
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_stone
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
				holding_type = tribal
				holding_type = temple
				holding_type = castle
				holding_type = city
				holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_stone }
			}
			location = { NOT = { has_province_modifier = guilds_buff_stone } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_metal_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_metal } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_stone } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_stone
							months = 12
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_stone } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_metal 
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.025 min = 2 max = 25 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_metal } 
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.0375 min = 4 max = 38 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = { location = { has_settlement_construction = yes } }
						custom_tooltip = { text = guilds_goods_bonus_construction_tooltip }
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #construction bonus
					}
					if = {
						limit = {
							location = {
								OR = {
									terrain = hills
									terrain = mountain
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = -0.02 min = -2 max = -20 } } #terrain malus
					}
					if = {
						limit = {
							location = {
								OR = {
									terrain = jungle
									terrain = steppe
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = 0.02 min = 2 max = 20 } } #terrain bonus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_steel = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 18
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_steel
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_steel }
			}
			location = { NOT = { has_province_modifier = guilds_buff_steel } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_metal_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_metal } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_steel } }
				}
				75 = {
					location = { #fake tooltip
						add_province_modifier = {
							name = guilds_buff_steel_empty
							months = 24
						}
					}
					hidden_tooltip = { #tooltip too big for decision
						location = {
							add_province_modifier = {
								name = guilds_buff_steel
								months = 24
							}
						}
						FROM = { character_event = { id = SNW.267 }  }
					}
					custom_tooltip = { text = guilds_atk_bonus_tooltip }
					custom_tooltip = { text = guilds_def_bonus_tooltip }
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_steel } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_metal
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.15 min = 15 max = 150 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_metal } 
						FROM = { scaled_wealth = { value = 0.30 min = 30 max = 300 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.225 min = 23 max = 225 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								NOR = {
									has_province_modifier = prosperity_modifier_1
									has_province_modifier = prosperity_modifier_2
									has_province_modifier = prosperity_modifier_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.05 min = -5 max = -50 } } #prosperity malus
					}
					if = {
						limit = {
							location = {
								OR = {
									terrain = farmlands
									terrain = plains
									terrain = forest
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #terrain bonus
					}
					if = {
						limit = { FROM = { war = yes } } 
						custom_tooltip = { text = guilds_goods_bonus_war_tooltip }
						FROM = { scaled_wealth = { value = 0.1 min = 10 max = 100 } } #war bonus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_gem = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 24
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_gem
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_gem }
			}
			location = { NOT = { has_province_modifier = guilds_buff_gem } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_metal_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_metal } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_gem } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_gem
							months = 36
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_gem } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_metal
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.27 min = 27 max = 275 } } #half minimum rounded down min/max
					}
					if = {
						FROM = { scaled_wealth = { value = 0.55 min = 55 max = 550 } } #minimum
						limit = { has_holding_modifier = guilds_shop_stall_metal } 
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.412 min = 41 max = 412 } } #In between half and the minimu, rounded up min/max
					}
					if = { 
						limit = { 
							has_dlc = "Reapers"
							location = { 
								has_province_modifier = prosperity_modifier_2 
							} 
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.1 min = 10 max = 100 } } #prosperity bonus
					}
					if = { 
						limit = { 
							has_dlc = "Reapers"
							location = { 
								OR = {
									has_province_modifier = prosperity_modifier_3
									has_province_modifier = prosperity_modifier_1
								}
							} 
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #prosperity bonus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								OR = {
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.1 min = -10 max = -100 } } #prosperity malus
					}
					if = {
						limit = {
							location = {
								OR = {
									terrain = hills
									terrain = mountain
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = -0.125 min = -12 max = -125 } } #terrain malus
					}
					if = {
						limit = { location = { has_epidemic = yes } }
						custom_tooltip = { text = guilds_goods_bonus_epidemic_tooltip }
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #epidemic bonus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_silver = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 30
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_silver
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_silver }
			}
			location = { NOT = { has_province_modifier = guilds_buff_silver } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_metal_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_metal } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_silver } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_silver
							months = 48
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_silver } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_metal
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.40 min = 40 max = 400 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_metal } 
						FROM = { scaled_wealth = { value = 0.80 min = 80 max = 800 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.60 min = 60 max = 600 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								OR = {
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.2 min = -20 max = -200 } } #prosperity malus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								NOR = {
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
									has_province_modifier = prosperity_modifier_1
									has_province_modifier = prosperity_modifier_2
									has_province_modifier = prosperity_modifier_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.1 min = -10 max = -100 } } #prosperity malus
					}
					if = {
						limit = {
							location = {
								OR = {
									terrain = hills
									terrain = mountain
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = -0.15 min = -15 max = -150 } } #terrain malus
					}
					if = {
						limit = { location = { has_epidemic = yes } }
						custom_tooltip = { text = guilds_goods_bonus_epidemic_tooltip }
						FROM = { scaled_wealth = { value = 0.20 min = 20 max = 200 } } #epidemic bonus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_gold = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 36
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_gold
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_gold }
			}
			location = { NOT = { has_province_modifier = guilds_buff_gold } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_metal_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_metal } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_gold } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_gold
							months = 60
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_gold } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_metal
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.525 min = 52 max = 525 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_metal } 
						FROM = { scaled_wealth = { value = 1.05 min = 105 max = 1050 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.788 min = 79 max = 788 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								OR = {
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.35 min = -350 max = -350 } } #prosperity malus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								OR = {
									has_province_modifier = prosperity_modifier_2
									has_province_modifier = prosperity_modifier_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.1 min = 10 max = 100 } } #prosperity bonus
					}
					if = {
						limit = { location = { has_epidemic = yes } }
						custom_tooltip = { text = guilds_goods_bonus_epidemic_tooltip }
						FROM = { scaled_wealth = { value = -0.1 min = -10 max = -100 } } #epidemic malus
					}
					if = {
						limit = { FROM = { war = yes } } 
						custom_tooltip = { text = guilds_goods_bonus_war_tooltip }
						FROM = { scaled_wealth = { value = -0.2 min = -20 max = -200 } } #war malus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_grain = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 12
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_grain
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_grain }
			}
			location = { NOT = { has_province_modifier = guilds_buff_grain } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_vegetal_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_vegetal } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_grain } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_grain
							months = 12
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_grain } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_vegetal
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.025 min = 2 max = 25 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_vegetal } 
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.0375 min = 4 max = 38 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = {
							has_dlc = "Reapers"
							location = { 
								OR = { 
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.10 min = 10 max = 100 } } #prosperity bonus
					}
					if = {
						limit = {
							location = {
								terrain = farmlands
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = -0.015 min = -1 max = -15 } } #terrain malus
					}
					if = {
						limit = {
							location = {
								OR = {
									terrain = plains
									terrain = steppe 
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = -0.01 min = -1 max = -10 } } #terrain malus
					}
					if = {
						limit = {
							location = {
								OR = {
									terrain = desert
									terrain = mountain
									terrain = arctic
									is_winter = yes
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = 0.015 min = 1 max = 15 } } #terrain bonus
					}
					if = {
						limit = { FROM = { war = yes } } 
						custom_tooltip = { text = guilds_goods_bonus_war_tooltip }
						FROM = { scaled_wealth = { value = 0.025 min = 2 max = 25 } } #war bonus
					}
					if = {
						limit = { 
							FROM = { 
								or = {
									has_character_modifier = guilds_buff_feast
									has_character_modifier = fabulous_feast
									has_character_modifier = holding_large_feast
									has_character_modifier = holding_diwali_feast 
									has_character_modifier = holding_kali_puja_feast
									has_character_modifier = holding_zun_feast
									has_character_flag = holding_blot
									has_character_flag = holding_ukon_juhla
									has_character_flag = holding_uzgavenes
									has_character_flag = holding_jarilo
									# has_character_modifier = holding_summer_fair
									# has_character_flag = tournament_begins
									# has_character_flag = tournament_begins_furusiyya
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_festivitie_tooltip }
						FROM = { scaled_wealth = { value = 0.02 min = 2 max = 20 } } #festivitie bonus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_lumber = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 18
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_lumber
			is_inaccessible_or_incapable_guilds_trigger = yes
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		
		allow = {
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_lumber }
			}
			location = { NOT = { has_province_modifier = guilds_buff_lumber } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_vegetal_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_vegetal } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_lumber } }
				}
				75 = {
					location = {
						add_province_modifier = {
								name = guilds_buff_lumber
								months = 24
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_lumber } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_vegetal
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.15 min = 15 max = 150 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_vegetal } 
						FROM = { scaled_wealth = { value = 0.30 min = 30 max = 300 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.225 min = 23 max = 225 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = { location = { has_settlement_construction = yes } }
						custom_tooltip = { text = guilds_goods_bonus_construction_tooltip }
						FROM = { scaled_wealth = { value = 0.075 min = 7 max = 75 } } #construction bonus
					}
					if = {
						limit = {
							location = {
								OR = {
									terrain = jungle
									terrain = forest
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = -0.05 min = -5 max = -50 } } #terrain malus
					}
					if = {
						limit = {
							location = {
								OR = {
									terrain = desert
									terrain = steppe
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #terrain bonus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_linen = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 24
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_linen
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_linen }
			}
			location = { NOT = { has_province_modifier = guilds_buff_linen } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_vegetal_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_vegetal } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_linen } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_linen
							months = 36
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_linen } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_vegetal
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.27 min = 27 max = 275 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_vegetal } 
						FROM = { scaled_wealth = { value = 0.55 min = 55 max = 550 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.412 min = 41 max = 412 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = { location = { has_province_modifier = guilds_buff_dye } }
						custom_tooltip = { text = guilds_goods_bonus_goods_tooltip }
						FROM = { scaled_wealth = { value = 0.10 min = 10 max = 100 } } #goods bonus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = { 
								OR = {
									has_province_modifier = prosperity_modifier_2
									has_province_modifier = prosperity_modifier_3
								}
							} 
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.1 min = 10 max = 100 } } #prosperity bonus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								OR = {
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.1 min = -10 max = -100 } } #prosperity malus
					}
					if = {
						limit = {
							location = {
								OR = {
									terrain = farmlands
									terrain = jungle
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = -0.05 min = -5 max = -50 } } #terrain malus
					}
					if = {
						limit = {
							location = {
								OR = {
									terrain = desert
									terrain = arctic
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #terrain bonus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_incense = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 30
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_incense
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_incense }
			}
			location = { NOT = { has_province_modifier = guilds_buff_incense } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_vegetal_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_vegetal } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_incense } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_incense
							months = 48
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_incense } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_vegetal
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.40 min = 40 max = 400 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_vegetal } 
						FROM = { scaled_wealth = { value = 0.80 min = 80 max = 800 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.60 min = 60 max = 600 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = { 
							FROM = { 
								or = {
									has_character_modifier = holding_diwali_feast 
									has_character_modifier = holding_kali_puja_feast

								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_festivitie_tooltip }
						FROM = { scaled_wealth = { value = 0.15 min = 15 max = 150 } } #festivitie bonus
					}
					if = {
						limit = { location = { has_epidemic = yes } }
						custom_tooltip = { text = guilds_goods_bonus_epidemic_tooltip }
						FROM = { scaled_wealth = { value = 0.10 min = 10 max = 100 } } #epidemic bonus
					}
					if = {
						limit = {
							holding_type = temple
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = 0.1 min = 10 max = 100 } } #terrain bonus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_spices = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 36
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_spices
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_spices }
			}
			location = { NOT = { has_province_modifier = guilds_buff_spices } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_vegetal_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_vegetal } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_spices } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_spices
							months = 60
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_spices } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_vegetal
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.525 min = 52 max = 525 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_vegetal } 
						FROM = { scaled_wealth = { value = 1.05 min = 105 max = 1050 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.788 min = 79 max = 788 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								OR = {
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.20 min = -200 max = -200 } } #prosperity malus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								OR = {
									has_province_modifier = prosperity_modifier_2
									has_province_modifier = prosperity_modifier_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.1 min = 10 max = 100 } } #prosperity bonus
					}
					if = {
						limit = { 
							FROM = { 
								or = {
									has_character_modifier = guilds_buff_feast
									has_character_modifier = fabulous_feast
									has_character_modifier = holding_large_feast
									has_character_modifier = holding_diwali_feast 
									has_character_modifier = holding_kali_puja_feast
									has_character_modifier = holding_zun_feast
									has_character_flag = holding_blot
									has_character_flag = holding_ukon_juhla
									has_character_flag = holding_uzgavenes
									has_character_flag = holding_jarilo
									# has_character_modifier = holding_summer_fair
									# has_character_flag = tournament_begins
									# has_character_flag = tournament_begins_furusiyya
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_festivitie_tooltip }
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #festivitie bonus
					}
					if = {
						limit = {
							location = {
								OR = {
									terrain = jungle
									terrain = desert
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = -0.15 min = -15 max = -150 } } #terrain malus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_meat = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 12
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_meat
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_meat }
			}
			location = { NOT = { has_province_modifier = guilds_buff_meat } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_animal_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_animal } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_meat } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_meat
							months = 12
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_meat } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_animal
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.025 min = 2 max = 25 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_animal } 
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.0375 min = 4 max = 38 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = {
							has_dlc = "Reapers"
							location = { 
								OR = { 
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.10 min = 10 max = 100 } } #prosperity bonus
					}
					if = {
						limit = { FROM = { war = yes } } 
						custom_tooltip = { text = guilds_goods_bonus_war_tooltip }
						FROM = { scaled_wealth = { value = 0.025 min = 2 max = 25 } } #war bonus
					}
					if = {
						limit = { 
							FROM = { 
								or = {
									has_character_modifier = guilds_buff_feast
									has_character_modifier = fabulous_feast
									has_character_modifier = holding_large_feast
									has_character_modifier = holding_diwali_feast 
									has_character_modifier = holding_kali_puja_feast
									has_character_modifier = holding_zun_feast
									has_character_flag = holding_blot
									has_character_flag = holding_ukon_juhla
									has_character_flag = holding_uzgavenes
									has_character_flag = holding_jarilo
									# has_character_modifier = holding_summer_fair
									# has_character_flag = tournament_begins
									# has_character_flag = tournament_begins_furusiyya
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_festivitie_tooltip }
						FROM = { scaled_wealth = { value = 0.02 min = 2 max = 20 } } #festivitie bonus
					}
					if = {
						limit = { location = { has_province_modifier = guilds_buff_spices } }
						custom_tooltip = { text = guilds_goods_bonus_goods_tooltip }
						FROM = { scaled_wealth = { value = 0.02 min = 2 max = 20 } } #goods bonus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_wool = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 18
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_wool
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_wool }
			}
			location = { NOT = { has_province_modifier = guilds_buff_wool } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_animal_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_animal } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_wool } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_wool
							months = 24
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_wool } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_animal
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.15 min = 15 max = 150 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_animal } 
						FROM = { scaled_wealth = { value = 0.30 min = 30 max = 300 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.225 min = 23 max = 225 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = { location = { has_province_modifier = guilds_buff_dye } }
						custom_tooltip = { text = guilds_goods_bonus_goods_tooltip }
						FROM = { scaled_wealth = { value = 0.10 min = 10 max = 100 } } #goods bonus
					}
					if = {
						limit = {
							location = {
								OR = {
									terrain = farmlands
									terrain = plains
									terrain = steppe 
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = -0.05 min = -5 max = -50 } } #terrain malus
					}
					if = {
						limit = {
							location = {
								OR = {
									terrain = arctic
									is_winter = yes
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = 0.1 min = 10 max = 100 } } #terrain bonus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = { 
								OR = {
									has_province_modifier = prosperity_modifier_2
									has_province_modifier = prosperity_modifier_3
								}
							} 
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.05 min = -5 max = -50 } } #prosperity malus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_hide = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 24
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_hide
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_hide }
			}
			location = { NOT = { has_province_modifier = guilds_buff_hide } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_animal_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_animal } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_hide } }
				}
				75 = {
					location = { #fake tooltip
						add_province_modifier = {
							name = guilds_buff_hide_empty
							months = 36
						}
					}
					hidden_tooltip = { #tooltip too big for decision
						location = {
							add_province_modifier = {
								name = guilds_buff_hide
								months = 36
							}
						}
						FROM = { character_event = { id = SNW.267 }  }
					}
					custom_tooltip = { text = guilds_def_bonus_tooltip }
					custom_tooltip = { text = guilds_levy_bonus_tooltip }
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_hide } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_animal
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.27 min = 27 max = 275 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_animal } 
						FROM = { scaled_wealth = { value = 0.55 min = 55 max = 550 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.412 min = 41 max = 412 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = { FROM = { war = yes } } 
						custom_tooltip = { text = guilds_goods_bonus_war_tooltip }
						FROM = { scaled_wealth = { value = 0.1 min = 10 max = 100 } } #war bonus
					}
					if = {
						limit = {
							location = {
								OR = {
									terrain = farmlands
									terrain = plains
									terrain = forest
									terrain = jungle
									terrain = steppe
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = -0.05 min = -5 max = -50 } } #terrain malus
					}
					if = {
						limit = { location = { has_epidemic = yes } }
						custom_tooltip = { text = guilds_goods_bonus_epidemic_tooltip }
						FROM = { scaled_wealth = { value = -0.1 min = -10 max = -100 } } #epidemic malus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_ivory = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 30
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_ivory
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_ivory }
			}
			location = { NOT = { has_province_modifier = guilds_buff_ivory } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_animal_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_animal } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_ivory } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_ivory
							months = 48
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_ivory } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_animal
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.40 min = 40 max = 400 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_animal } 
						FROM = { scaled_wealth = { value = 0.80 min = 80 max = 800 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.60 min = 60 max = 600 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = {
							location = {
								OR = {
									terrain = jungle
									terrain = arctic
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = -0.1 min = -10 max = -100 } } #terrain malus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								OR = {
									has_province_modifier = prosperity_modifier_3
									has_province_modifier = prosperity_modifier_2
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #prosperity bonus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								OR = {
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.3 min = -30 max = -300 } } #prosperity malus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								NOR = {
									has_province_modifier = prosperity_modifier_3
									has_province_modifier = prosperity_modifier_2
									has_province_modifier = prosperity_modifier_1
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.1 min = -10 max = -100 } } #prosperity malus
					}
					if = {
						limit = { location = { has_epidemic = yes } }
						custom_tooltip = { text = guilds_goods_bonus_epidemic_tooltip }
						FROM = { scaled_wealth = { value = -0.05 min = -5 max = -50 } } #epidemic malus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_silk = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 36
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_silk
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_silk }
			}
			location = { NOT = { has_province_modifier = guilds_buff_silk } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_animal_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_animal } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_silk } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_silk
							months = 60
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_silk } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_animal
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.525 min = 52 max = 525 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_animal } 
						FROM = { scaled_wealth = { value = 1.05 min = 105 max = 1050 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.788 min = 79 max = 788 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = { location = { has_province_modifier = guilds_buff_dye } }
						custom_tooltip = { text = guilds_goods_bonus_goods_tooltip }
						FROM = { scaled_wealth = { value = 0.10 min = 10 max = 100 } } #goods bonus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								OR = {
									has_province_modifier = prosperity_modifier_3
									has_province_modifier = prosperity_modifier_2
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #prosperity bonus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								OR = {
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.15 min = -15 max = -150 } } #prosperity malus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								NOR = {
									has_province_modifier = prosperity_modifier_3
									has_province_modifier = prosperity_modifier_2
									has_province_modifier = prosperity_modifier_1
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.1 min = -10 max = -100 } } #prosperity malus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_pottery = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 12
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_pottery
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_pottery }
			}
			location = { NOT = { has_province_modifier = guilds_buff_pottery } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_final_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_final } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_pottery } }
				}
			 	75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_pottery
							months = 12
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_pottery } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_goods
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.025 min = 2 max = 25 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_goods } 
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.0375 min = 4 max = 38 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = {
							has_dlc = "Reapers"
							location = { 
								NOR = { 
									has_province_modifier = prosperity_modifier_2
									has_province_modifier = prosperity_modifier_3
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.01 min = 1 max = 10 } } #prosperity bonus
					}
					if = {
						limit = { 
							location = { 
								OR = {
									has_province_modifier = guilds_buff_alcohol 
									has_province_modifier = guilds_buff_grain
									has_province_modifier = guilds_buff_meat
								} 
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_goods_tooltip }
						FROM = { scaled_wealth = { value = 0.015 min = 1 max = 15 } } #goods bonus
					}
				}
			}    
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_alcohol = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 18
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_alcohol
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_alcohol }
			}
			location = { NOT = { has_province_modifier = guilds_buff_alcohol } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_final_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_final } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_alcohol } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_alcohol
							months = 24
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_alcohol } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_goods
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.15 min = 15 max = 150 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_goods } 
						FROM = { scaled_wealth = { value = 0.30 min = 30 max = 300 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.225 min = 23 max = 225 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = {
							has_dlc = "Reapers"
							location = { 
								OR = {
									has_province_modifier = prosperity_modifier_1
									has_province_modifier = prosperity_modifier_2
									has_province_modifier = prosperity_modifier_3
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #prosperity bonus
					}
					if = {
						limit = {
							has_dlc = "Reapers"
							location = { 
								OR = {
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.1 min = 10 max = 100 } } #prosperity bonus
					}
					if = {
						limit = { FROM = { war = yes } } 
						custom_tooltip = { text = guilds_goods_bonus_war_tooltip }
						FROM = { scaled_wealth = { value = 0.075 min = 7 max = 75 } } #war bonus
					}
					if = { limit = { location = { is_winter = yes } }
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = 0.1 min = 10 max = 100 } } #terrain bonus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_armor = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 24
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_armor
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_armor }
			}
			location = { NOT = { has_province_modifier = guilds_buff_armor } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_final_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_final } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_armor } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_armor
							months = 36
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_armor } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_goods
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.27 min = 27 max = 275 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_goods } 
						FROM = { scaled_wealth = { value = 0.55 min = 55 max = 550 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.412 min = 41 max = 412 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = { FROM = { war = yes } } 
						custom_tooltip = { text = guilds_goods_bonus_war_tooltip }
						FROM = { scaled_wealth = { value = 0.20 min = 20 max = 200 } } #At war bonus
					}
					if = {
						limit = { FROM = { war = no } }
 						custom_tooltip = { text = guilds_goods_bonus_war_tooltip }
						FROM = { scaled_wealth = { value = -0.10 min = -10 max = -100 } } #At war malus
					}
					if = {
						limit = { 
							FROM = { 
								or = {
									has_character_flag = tournament_begins
									has_character_flag = tournament_begins_furusiyya
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_festivitie_tooltip }
						FROM = { scaled_wealth = { value = 0.1 min = 1 max = 100 } } #festivitie bonus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_jewelry = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 30
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_jewelry
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_jewelry }
			}
			location = { NOT = { has_province_modifier = guilds_buff_jewelry } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_final_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_final } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_jewelry } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_jewelry
							months = 48
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_jewelry } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_goods
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.40 min = 40 max = 400 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_goods } 
						FROM = { scaled_wealth = { value = 0.80 min = 80 max = 800 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.60 min = 60 max = 600 } } #In between half and the minimu, rounded up min/max
					}
					if = { 
						limit = { 
							has_dlc = "Reapers"
							location = { 
								has_province_modifier = prosperity_modifier_1
							} 
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #prosperity bonus
					}
					if = { 
						limit = { 
							has_dlc = "Reapers"
							location = { 
								OR = {
									has_province_modifier = prosperity_modifier_3
									has_province_modifier = prosperity_modifier_2
								}
							} 
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.1 min = 10 max = 100 } } #prosperity bonus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								OR = {
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.2 min = -20 max = -200 } } #prosperity malus
					}
					if = {
						limit = { 
							location = { 
								OR = {
									has_province_modifier = guilds_buff_gem
									has_province_modifier = guilds_buff_silver 
									has_province_modifier = guilds_buff_gold 
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_goods_tooltip }
						FROM = { scaled_wealth = { value = -0.1 min = -10 max = -100 } } #goods malus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_book = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 36 
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_book
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_book }
			}
			location = { NOT = { has_province_modifier = guilds_buff_book } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_final_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_final } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_book } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_book
							months = 60
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_book } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_goods
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.525 min = 52 max = 525 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_goods } 
						FROM = { scaled_wealth = { value = 1.05 min = 105 max = 1050 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.788 min = 79 max = 788 } } #In between half and the minimu, rounded up min/max
					}
					if = { 
						limit = { 
							has_dlc = "Reapers"
							location = { 
								has_province_modifier = prosperity_modifier_1
							} 
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #prosperity bonus
					}
					if = { 
						limit = { 
							has_dlc = "Reapers"
							location = { 
								OR = {
									has_province_modifier = prosperity_modifier_3
									has_province_modifier = prosperity_modifier_2
								}
							} 
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.1 min = 10 max = 100 } } #prosperity bonus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								OR = {
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.2 min = -20 max = -200 } } #prosperity malus
					}
					if = {
						limit = { 
							OR = {
							 	holding_type = temple
								holding_type = city
							} 
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = 0.1 min = 10 max = 100 } } #terrain bonus
					}
					if = {
						limit = { 
							OR = {
								holding_type = tribal
								holding_type = nomad 
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = -0.3 min = -30 max = -300 } } #terrain malus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_statue = { #< v crafted stuffs
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 120
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_statue
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_statue }
			}
			location = { NOT = { has_province_modifier = guilds_buff_statue } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_metal_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_metal } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_statue } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_statue
							months = 24
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_statue } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_metal
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.15 min = 15 max = 150 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_metal } 
						FROM = { scaled_wealth = { value = 0.30 min = 30 max = 300 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.225 min = 23 max = 225 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = { location = { has_settlement_construction = yes } }
						custom_tooltip = { text = guilds_goods_bonus_construction_tooltip }
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #construction bonus
					}
					if = { 
						limit = { 
							has_dlc = "Reapers"
							location = { 
								has_province_modifier = prosperity_modifier_1
							} 
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #prosperity bonus
					}
					if = { 
						limit = { 
							has_dlc = "Reapers"
							location = { 
								has_province_modifier = prosperity_modifier_2
							} 
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.1 min = 10 max = 100 } } #prosperity bonus
					}
					if = { 
						limit = { 
							has_dlc = "Reapers"
							location = { 
								has_province_modifier = prosperity_modifier_3
							} 
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.15 min = 15 max = 150 } } #prosperity bonus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_music = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 120
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_music
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_music }
			}
			location = { NOT = { has_province_modifier = guilds_buff_music } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_final_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_final } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_music } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_music
							months = 48
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_music } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_goods
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.40 min = 40 max = 400 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_goods } 
						FROM = { scaled_wealth = { value = 0.80 min = 80 max = 800 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.60 min = 60 max = 600 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = { 
							FROM = { 
								or = {
									has_character_modifier = guilds_buff_feast
									has_character_modifier = fabulous_feast
									has_character_modifier = holding_large_feast
									has_character_modifier = holding_diwali_feast 
									has_character_modifier = holding_kali_puja_feast
									has_character_modifier = holding_zun_feast
									has_character_flag = holding_blot
									has_character_flag = holding_ukon_juhla
									has_character_flag = holding_uzgavenes
									has_character_flag = holding_jarilo
									has_character_modifier = holding_summer_fair
									has_character_flag = tournament_begins
									has_character_flag = tournament_begins_furusiyya
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_festivitie_tooltip }
						FROM = { scaled_wealth = { value = 0.15 min = 15 max = 150 } } #festivitie bonus
					}
					if = {
						limit = {
							has_dlc = "Reapers"
							location = { 
								OR = {
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.1 min = -10 max = -100 } } #prosperity malus
					}
					if = {
						limit = { location = { has_epidemic = yes } }
						custom_tooltip = { text = guilds_goods_bonus_epidemic_tooltip }
						FROM = { scaled_wealth = { value = -0.05 min = -5 max = -50 } } #epidemic malus
					}
				}
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_glassware = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 120
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_glassware
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_glassware }
			}
			location = { NOT = { has_province_modifier = guilds_buff_glassware } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_final_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_final } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_glassware } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_glassware
							months = 48
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_glassware } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_goods
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.40 min = 40 max = 400 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_goods } 
						FROM = { scaled_wealth = { value = 0.80 min = 80 max = 800 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.60 min = 60 max = 600 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = { location = { has_settlement_construction = yes } }
						custom_tooltip = { text = guilds_goods_bonus_construction_tooltip }
						FROM = { scaled_wealth = { value = 0.10 min = 10 max = 100 } } #construction bonus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								NOR = {
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
									has_province_modifier = prosperity_modifier_1
									has_province_modifier = prosperity_modifier_2
									has_province_modifier = prosperity_modifier_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.05 min = -5 max = -50 } } #prosperity malus
					}
					if = { 
						limit = { 
							has_dlc = "Reapers"
							location = { 
								has_province_modifier = prosperity_modifier_2
							} 
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.1 min = 10 max = 100 } } #prosperity bonus
					}
					if = { 
						limit = { 
							has_dlc = "Reapers"
							location = { 
								has_province_modifier = prosperity_modifier_3
							} 
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.15 min = 15 max = 150 } } #prosperity bonus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								OR = {
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.10 min = -10 max = -100 } } #prosperity malus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_dye = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 120
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_dye
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_dye }
			}
			location = { NOT = { has_province_modifier = guilds_buff_dye } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_final_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_final } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_dye } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_dye
							months = 60
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_dye } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_goods
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.525 min = 52 max = 525 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_goods } 
						FROM = { scaled_wealth = { value = 1.05 min = 105 max = 1050 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.788 min = 79 max = 788 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = { 
							FROM = { 
								OR = {
									has_character_modifier = holding_diwali_feast 
									has_character_modifier = holding_kali_puja_feast
									has_character_modifier = holding_summer_fair
									has_character_flag = tournament_begins
									has_character_flag = tournament_begins_furusiyya
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_festivitie_tooltip }
						FROM = { scaled_wealth = { value = 0.1 min = 10 max = 100 } } #festivitie bonus
					}
					if = {
						limit = {
							has_dlc = "Reapers"
							location = { 
								OR = {
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.15 min = -15 max = -150 } } #prosperity malus
					}
					if = { 
						limit = { 
							has_dlc = "Reapers"
							location = { 
								OR = {
									has_province_modifier = prosperity_modifier_2
									has_province_modifier = prosperity_modifier_3
								}
							} 
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #prosperity bonus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_velvet = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 120
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_velvet
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_velvet }
			}
			location = { NOT = { has_province_modifier = guilds_buff_velvet } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_final_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_final } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_velvet } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_velvet
							months = 48
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_velvet } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_goods
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.40 min = 40 max = 400 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_goods } 
						FROM = { scaled_wealth = { value = 0.80 min = 80 max = 800 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.60 min = 60 max = 600 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = { location = { has_province_modifier = guilds_buff_dye } }
						custom_tooltip = { text = guilds_goods_bonus_goods_tooltip }
						FROM = { scaled_wealth = { value = 0.10 min = 10 max = 100 } } #goods bonus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								has_province_modifier = prosperity_modifier_3
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.1 min = 10 max = 100 } } #prosperity bonus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								OR = {
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.2 min = -20 max = -200 } } #prosperity malus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = {
								NOR = {
									has_province_modifier = prosperity_modifier_3
									has_province_modifier = prosperity_modifier_2
									has_province_modifier = depopulated_1
									has_province_modifier = depopulated_2
									has_province_modifier = depopulated_3
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = -0.1 min = -10 max = -100 } } #prosperity malus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	guilds_buffing_fur = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 120
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 2
			has_artifact = guilds_item_fur
		}
		
		potential = {
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			custom_tooltip = {
				text = guilds_buffing_goods_tooltip
				FROM = { has_artifact = guilds_item_fur }
			}
			location = { NOT = { has_province_modifier = guilds_buff_fur } }
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
			custom_tooltip = {
				text = guilds_smugglers_ring_animal_tooltip
				location = { NOT = { has_province_modifier = guilds_smugglers_ring_animal } }
			}
		}
		
		effect = {
			random_list = {
				25 = { 
					modifier = {
						factor = 0
						FROM = { NOT = { has_character_modifier = guilds_thieves_guild } }
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_fur } }
				}
				75 = {
					location = {
						add_province_modifier = {
							name = guilds_buff_fur
							months = 48
						}
					}
					hidden_tooltip = { FROM = { destroy_artifact = guilds_item_fur } }
					if = {
						limit = { 
							NOR = { 
								has_holding_modifier = guilds_shop_stall_animal
								has_holding_modifier = guilds_shop_stall_general
							}
						}
						FROM = { scaled_wealth = { value = 0.40 min = 40 max = 400 } } #half minimum rounded down min/max
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_animal } 
						FROM = { scaled_wealth = { value = 0.80 min = 80 max = 800 } } #minimum
					}
					if = {
						limit = { has_holding_modifier = guilds_shop_stall_general } 
						FROM = { scaled_wealth = { value = 0.60 min = 60 max = 600 } } #In between half and the minimu, rounded up min/max
					}
					if = {
						limit = { location = { is_winter = yes } } 
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = 0.20 min = 20 max = 200 } } #terrain bonus
					}
					if = {
						limit = {
							location = {
								OR = {
									terrain = forest
									terrain = arctic
									terrain = steppe 
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_terrain_tooltip }
						FROM = { scaled_wealth = { value = -0.05 min = -5 max = -50 } } #terrain malus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = { 
								has_province_modifier = prosperity_modifier_1
							} 
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.05 min = 5 max =  50 } } #prosperity bonus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = { 
								has_province_modifier = prosperity_modifier_2
							} 
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.075 min = 7 max =  75 } } #prosperity bonus
					}
					if = {
						limit = { 
							has_dlc = "Reapers"
							location = { 
								has_province_modifier = prosperity_modifier_3
							} 
						}
						custom_tooltip = { text = guilds_goods_bonus_prosperity_tooltip }
						FROM = { scaled_wealth = { value = 0.10 min = 10 max =  100 } } #prosperity bonus
					}
					if = {
						limit = { 
							FROM = { 
								OR = {
									has_character_flag = holding_blot
									has_character_flag = holding_ukon_juhla
									has_character_flag = holding_uzgavenes
									has_character_flag = holding_jarilo
								}
							}
						}
						custom_tooltip = { text = guilds_goods_bonus_festivitie_tooltip }
						FROM = { scaled_wealth = { value = 0.05 min = 5 max = 50 } } #festivitie bonus
					}
				}
			}
			hidden_tooltip = {
				FROM = { change_variable = { which = guildsxp value = 1 } }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
#Shops and stalls
	guilds_shopping_stall_metal = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		ai_check_interval = 13
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 3
			has_artifact = guilds_item_shop_stall
			is_inaccessible_or_incapable_guilds_trigger = yes
		}
		
		potential = {
			# location = { is_capital = yes }
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
			NOR = {
			has_holding_modifier = guilds_shop_stall_metal 
			has_holding_modifier = guilds_shop_stall_vegetal 
			has_holding_modifier = guilds_shop_stall_animal 
			has_holding_modifier = guilds_shop_stall_goods 
			has_holding_modifier = guilds_shop_stall_general
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			FROM = { influence_cost_caravan_trigger = yes }
			# owner = { scaled_wealth = 1 }
			NOR = {
			has_holding_modifier = guilds_shop_stall_metal 
			has_holding_modifier = guilds_shop_stall_vegetal 
			has_holding_modifier = guilds_shop_stall_animal 
			has_holding_modifier = guilds_shop_stall_goods 
			has_holding_modifier = guilds_shop_stall_general
			}
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
		}
		
		effect = {
			add_holding_modifier = {
				name = guilds_shop_stall_metal
				months = 120
			}
			FROM = { influence_cost_caravan_effect = yes }
			FROM = { destroy_artifact = guilds_item_shop_stall }
			FROM = { character_event = { id = SNW.180 days = 4500 }  }
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 0.25
				modifier = {
					factor = 0
					NOT = { wealth = 30 }
				}
				modifier = {
					factor = 2
					scaled_wealth = 0.5
				}
				modifier = {
					factor = 2
					society_currency = 200
				}
		}
	}
	guilds_shopping_stall_vegetal = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		ai_check_interval = 13
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 3
			has_artifact = guilds_item_shop_stall
			is_inaccessible_or_incapable_guilds_trigger = yes
		}
		
		potential = {
			# location = { is_capital = yes }
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
			NOR = {
			has_holding_modifier = guilds_shop_stall_metal 
			has_holding_modifier = guilds_shop_stall_vegetal 
			has_holding_modifier = guilds_shop_stall_animal 
			has_holding_modifier = guilds_shop_stall_goods 
			has_holding_modifier = guilds_shop_stall_general
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			FROM = { influence_cost_caravan_trigger = yes }
			# owner = { scaled_wealth = 1 }
			NOR = {
			has_holding_modifier = guilds_shop_stall_metal 
			has_holding_modifier = guilds_shop_stall_vegetal 
			has_holding_modifier = guilds_shop_stall_animal 
			has_holding_modifier = guilds_shop_stall_goods 
			has_holding_modifier = guilds_shop_stall_general
			}
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
		}
		
		effect = {
			add_holding_modifier = {
				name = guilds_shop_stall_vegetal
				months = 120
			}
			FROM = { influence_cost_caravan_effect = yes }
			FROM = { detract_society_currency_minor_effect = yes }
			FROM = { destroy_artifact = guilds_item_shop_stall }
			FROM = { character_event = { id = SNW.180 days = 4500 }  }
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
				modifier = {
					factor = 0.4
				}
		}
	}
	guilds_shopping_stall_animal = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		ai_check_interval = 13
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 3
			has_artifact = guilds_item_shop_stall
			is_inaccessible_or_incapable_guilds_trigger = yes
		}
		
		potential = {
			# location = { is_capital = yes }
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
			NOR = {
			has_holding_modifier = guilds_shop_stall_metal 
			has_holding_modifier = guilds_shop_stall_vegetal 
			has_holding_modifier = guilds_shop_stall_animal 
			has_holding_modifier = guilds_shop_stall_goods 
			has_holding_modifier = guilds_shop_stall_general
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			FROM = { influence_cost_caravan_trigger = yes }
			# owner = { scaled_wealth = 1 }
			NOR = {
			has_holding_modifier = guilds_shop_stall_metal 
			has_holding_modifier = guilds_shop_stall_vegetal 
			has_holding_modifier = guilds_shop_stall_animal 
			has_holding_modifier = guilds_shop_stall_goods 
			has_holding_modifier = guilds_shop_stall_general
			}
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
		}
		
		effect = {
			add_holding_modifier = {
				name = guilds_shop_stall_animal
				months = 120
			}
			FROM = { influence_cost_caravan_effect = yes }
			FROM = { detract_society_currency_minor_effect = yes }
			FROM = { destroy_artifact = guilds_item_shop_stall }
			FROM = { character_event = { id = SNW.180 days = 4500 }  }
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
				modifier = {
					factor = 0.6
				}
		}
	}
	guilds_shopping_stall_goods = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		ai_check_interval = 13
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 3
			has_artifact = guilds_item_shop_stall
			is_inaccessible_or_incapable_guilds_trigger = yes
		}
		
		potential = {
			# location = { is_capital = yes }
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
			NOR = {
			has_holding_modifier = guilds_shop_stall_metal 
			has_holding_modifier = guilds_shop_stall_vegetal 
			has_holding_modifier = guilds_shop_stall_animal 
			has_holding_modifier = guilds_shop_stall_goods 
			has_holding_modifier = guilds_shop_stall_general
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			FROM = { influence_cost_caravan_trigger = yes }
			# owner = { scaled_wealth = 1 }
			NOR = {
			has_holding_modifier = guilds_shop_stall_metal 
			has_holding_modifier = guilds_shop_stall_vegetal 
			has_holding_modifier = guilds_shop_stall_animal 
			has_holding_modifier = guilds_shop_stall_goods 
			has_holding_modifier = guilds_shop_stall_general
			}
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
		}
		
		effect = {
			add_holding_modifier = {
				name = guilds_shop_stall_goods
				months = 120
			}
			FROM = { influence_cost_caravan_effect = yes }
			FROM = { detract_society_currency_minor_effect = yes }
			FROM = { destroy_artifact = guilds_item_shop_stall }
			FROM = { character_event = { id = SNW.180 days = 4500 }  }
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
				modifier = {
					factor = 0.8
				}
		}
	}
	guilds_shopping_stall_general = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		ai_check_interval = 13
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 3
			has_artifact = guilds_item_shop_stall
			is_inaccessible_or_incapable_guilds_trigger = yes
		}
		
		potential = {
			# location = { is_capital = yes }
			owner = { character = FROM }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
			NOR = {
			has_holding_modifier = guilds_shop_stall_metal 
			has_holding_modifier = guilds_shop_stall_vegetal 
			has_holding_modifier = guilds_shop_stall_animal 
			has_holding_modifier = guilds_shop_stall_goods 
			has_holding_modifier = guilds_shop_stall_general
			}
		}
		allow = {
			FROM = { is_inaccessible_trigger = no }
			FROM = { influence_cost_caravan_trigger = yes }
			# owner = { scaled_wealth = 1 }
			NOR = {
			has_holding_modifier = guilds_shop_stall_metal 
			has_holding_modifier = guilds_shop_stall_vegetal 
			has_holding_modifier = guilds_shop_stall_animal 
			has_holding_modifier = guilds_shop_stall_goods 
			has_holding_modifier = guilds_shop_stall_general
			}
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
		}
		
		effect = {
			add_holding_modifier = {
				name = guilds_shop_stall_general
				months = 120
			}
			FROM = { influence_cost_caravan_effect = yes }
			FROM = { detract_society_currency_minor_effect = yes }
			FROM = { destroy_artifact = guilds_item_shop_stall }
			FROM = { character_event = { id = SNW.180 days = 4500 }  }
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
#Caravans 50/50 70/30 90/10
	guilds_shopping_caravan = {
		filter = all
		ai_target_filter = self
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds 
			society_rank >= 3
			has_artifact = guilds_item_shop_caravan
			is_inaccessible_or_incapable_guilds_trigger = yes
		}
		
		potential = {
			# location = { owner = { NOT = { character = FROM } } }
			# owner = { NOT = { character = FROM } }
			owner = { NOT = { character = FROM } }
			owner = { primary_title = { higher_tier_than = BARON } }
			OR = {
				holding_type = tribal
				holding_type = temple
				holding_type = castle
				holding_type = city
				holding_type = nomad
			}
		}
		allow = {
			FROM = { influence_cost_caravan_trigger = yes }
			FROM = {
				custom_tooltip = {
					text = guilds_preparing_caravan_tooltip
					NOT = { has_character_flag = guilds_preparing_caravan }
				}
			}
			location = {
				custom_tooltip = {
					text = guilds_shopping_caravan_shipment_tooltip
					OR = {
						has_province_modifier = guilds_buff_stone
						has_province_modifier = guilds_buff_steel
						has_province_modifier = guilds_buff_gem
						has_province_modifier = guilds_buff_silver
						has_province_modifier = guilds_buff_gold
						has_province_modifier = guilds_buff_grain
						has_province_modifier = guilds_buff_lumber
						has_province_modifier = guilds_buff_linen
						has_province_modifier = guilds_buff_incense
						has_province_modifier = guilds_buff_spices
						has_province_modifier = guilds_buff_meat
						has_province_modifier = guilds_buff_wool
						has_province_modifier = guilds_buff_hide
						has_province_modifier = guilds_buff_ivory
						has_province_modifier = guilds_buff_silk
						has_province_modifier = guilds_buff_pottery
						has_province_modifier = guilds_buff_alcohol
						has_province_modifier = guilds_buff_armor
						has_province_modifier = guilds_buff_jewelry
						has_province_modifier = guilds_buff_book
						has_province_modifier = guilds_buff_statue
						has_province_modifier = guilds_buff_music
						has_province_modifier = guilds_buff_glassware
						has_province_modifier = guilds_buff_dye
						has_province_modifier = guilds_buff_velvet
						has_province_modifier = guilds_buff_fur
					}
				}
				NOT = { has_province_modifier = guilds_shop_caravan }
			}
			FROM = { 
				custom_tooltip = {
					text = guilds_caravan_robber_tooltip
					NOR = { 
						has_character_modifier = guilds_highway_robber_band 
						has_character_flag = guilds_robber_caravan
					}
				}
			}
			custom_tooltip = {
				text = guilds_buffing_busy_tooltip
				FROM = { NOT = { has_character_flag = guilds_is_using_goods } }
			}
		}
		
		effect = {
			sound_effect = forest_event_3
			FROM = { influence_cost_caravan_effect = yes }
			hidden_tooltip = { FROM = { destroy_artifact = guilds_item_shop_caravan } }
			FROM = { clr_character_flag = guilds_prepared_caravan }
			FROM = {
				if = {
					limit = { has_character_modifier = guilds_highway_robber_band_military }
					scaled_wealth = -0.5
				}
			}
			hidden_tooltip = {  #too complicated, hidden tooltip
				if = {
					limit = {
						FROM = { 
							capital_holding = {
								has_holding_modifier = guilds_caravan_escort
							}
						}
					}
					FROM = {
						capital_holding  = {
							remove_holding_modifier = guilds_caravan_escort
						}
					}
					FROM = { 
						capital_holding  = {
							add_holding_modifier = {
								name = guilds_caravan_escort_timed
								months = 12
							}
						}
					}
				}
				FROM = { 
					add_character_modifier = {
							name = guilds_caravan_timer
							duration = 200
							hidden = yes
					}
				}
				random_list = {
					10 = {
						modifier = {
							factor = 0.5
							FROM = { has_character_flag = guilds_caravan_investment_security }
						}
						modifier = {
							factor = 2
							owner = { war = yes }
						}
						modifier = {
							factor = 3
							location = { has_province_modifier = highway_robber_band }
						}
						modifier = {
							factor = 4
							FROM = { has_character_modifier = guilds_highway_robber_band_dare }
						}
						random_list = {
							50 = {
								location = {
									add_province_modifier = {
										name = guilds_shop_caravan
										months = 18
									}
								}
							}
							50 = { }
						}
						FROM = { character_event = { id = SNW.193 days = 300 }  } #caravan missing
						FROM = {
							if = {
								limit = {
									has_quest = quest_guilds_caravan
								}
								character_event = { id = SNW.425 days = 300 }  #complete mission
							}
						}
					}
					90 = {
						if = {
							limit = {
								location = { distance = { who = FROM value = 800 } }
							}
							FROM = { character_event = { id = SNW.190 days = 700 }  } #caravan return
							FROM = {
								if = {
									limit = {
										has_quest = quest_guilds_caravan
									}
									character_event = { id = SNW.422 days = 700 }  #complete mission
								}
							}
						}
						else_if = {
							limit = {
								location = { distance = { who = FROM value = 400 } }
							}
							FROM = { character_event = { id = SNW.190 days = 500 }  } #caravan return
							FROM = {
								if = {
									limit = {
										has_quest = quest_guilds_caravan
									}
									character_event = { id = SNW.422 days = 500 }  #complete mission
								}
							}
						}
						else = {
							FROM = { character_event = { id = SNW.190 days = 300 }  } #caravan return
							FROM = {
								if = {
									limit = {
										has_quest = quest_guilds_caravan
									}
									character_event = { id = SNW.422 days = 300 }  #complete mission
								}
							}
						}
						location = {
							add_province_modifier = {
								name = guilds_shop_caravan
								months = 18
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_stone }
							}
							random_list = {
								10 = { }
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1901 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1901 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1901 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_steel }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1902 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1902 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1902 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_gem }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1903 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1903 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1903 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_silver }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1904 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1904 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1904 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_gold }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1905 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1905 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1905 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_grain }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1906 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1906 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1906 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_lumber }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1907 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1907 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1907 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_linen }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1908 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1908 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1908 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_incense }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1909 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1909 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1909 days = 301 }  }
									} 
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_spices }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1910 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1910 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1910 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_meat }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1911 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1911 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1911 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_wool }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1912 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1912 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1912 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_hide }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1913 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1913 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1913 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_ivory }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1914 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1914 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1914 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_silk }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1915 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1915 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1915 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_pottery }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1916 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1916 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1916 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_alcohol }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1917 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1917 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1917 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_armor }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1918 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1918 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1918 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_jewelry }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1919 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1919 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1919 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_book }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1920 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1920 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1920 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_statue }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1921 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1921 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1921 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_music }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1922 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1922 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1922 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_glassware }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1923 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1923 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1923 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_dye }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1924 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1924 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1924 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_velvet }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1925 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1925 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1925 days = 301 }  }
									}
								}
							}
						}
						if = {
							limit = {
								location = { has_province_modifier = guilds_buff_fur }
							}
							random_list = {
								10 = { } 
								10 = { # 50% chance of failure
									modifier = { 
										factor = 2.3 #~30% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_small }
									}
									modifier = {
										factor = 10 #~11% chance of failure
										FROM = { has_character_flag = guilds_caravan_investment_large }
									}
									if = {
										limit = {
											location = { distance = { who = FROM value = 800 } }
										}
										FROM = { character_event = { id = SNW.1926 days = 701 }  }
									}
									else_if = {
										limit = {
											location = { distance = { who = FROM value = 400 } }
										}
										FROM = { character_event = { id = SNW.1926 days = 501 }  }
									}
									else = {
										FROM = { character_event = { id = SNW.1926 days = 301 }  }
									}
								}
							}
						}
					}
				}
			}
			random_list = { #Tooltip for caravans
				10 = {
					modifier = {
						factor = 0.5
						FROM = { has_character_flag = guilds_caravan_investment_security }
					}
					modifier = {
						factor = 2
						owner = { war = yes }
					}
					modifier = {
						factor = 3
						location = { has_province_modifier = highway_robber_band }
					}
					modifier = {
						factor = 4
						FROM = { has_character_modifier = guilds_highway_robber_band_dare }
					}
					custom_tooltip = { text = guilds_caravan_fail_tooltip }
				}
				90 = {
					custom_tooltip = { text = guilds_caravan_win_tooltip }
					random_list = {
						10 = { custom_tooltip = { text = guilds_caravan_nothing_tooltip } } 
						10 = { 
							modifier = { 
								factor = 2.3 
								FROM = { has_character_flag = guilds_caravan_investment_small }
							}
							modifier = {
								factor = 10 
								FROM = { has_character_flag = guilds_caravan_investment_large }
							}
							custom_tooltip = { text = guilds_caravan_something_tooltip }
						}
					}
				}
			}
			FROM = { character_event = { id = SNW.199 }  } #hidden remove flags
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 0
			modifier = {
				factor = 0
				has_character_modifier = guilds_caravan_timer
			}
		}
	}
#Sabotage
	guilds_sabotaging_supply = { #player only
		filter = all
		ai_target_filter = realm_owned
		# is_high_prio = yes
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 3
			is_inaccessible_or_incapable_guilds_trigger = yes
		}
		
		potential = {
			location = { owner = { NOT = { character = FROM } } }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			owner = {
				OR = {
					is_foe = FROM
					AND = { 
						war_with = FROM
						OR = { 
							is_primary_war_attacker = yes
							is_primary_war_defender = yes
						}
					}
				}
			}
			owner = { NOT = { society_member_of = the_guilds } }
			FROM = { scaled_wealth = 0.5 }
			FROM = { society_currency >= 200 }
			location = { NOT = { has_province_modifier = guilds_sabotage_supply } }
			# owner = { has_raised_levies = yes }
		}
		
		effect = {
			owner = {
				any_demesne_province = {
					add_province_modifier = {
						name = guilds_sabotage_supply
						months = 12
					}
				}
			}
			FROM = { scaled_wealth = -0.5 }
			FROM = { detract_society_currency_minor_effect = yes }
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	guilds_sabotaging_economy = { #player only
		filter = all
		ai_target_filter = realm_owned
		# is_high_prio = yes
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 3
			is_inaccessible_or_incapable_guilds_trigger = yes
		}
		
		potential = {
			location = { owner = { NOT = { character = FROM } } }
			OR = {
				holding_type = tribal
				holding_type = temple
				holding_type = castle
				holding_type = city
				holding_type = nomad
			}
		}
		allow = {
			owner = {
				OR = {
					is_foe = FROM
					AND = { 
						war_with = FROM
						OR = { 
							is_primary_war_attacker = yes
							is_primary_war_defender = yes
						}
					}
				}
			}
			owner = { NOT = { society_member_of = the_guilds } }
			FROM = { scaled_wealth = 0.5 }
			FROM = { society_currency >= 200 }
			location = { NOT = { has_province_modifier = guilds_sabotage_economy } }
		}
		
		effect = {
			owner = {
				any_demesne_province = {
					add_province_modifier = {
						name = guilds_sabotage_economy
						months = 12
					}
				}
			}
			FROM = { scaled_wealth = -0.5 }
			FROM = { detract_society_currency_minor_effect = yes }
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	guilds_sabotaging_propaganda = { #player only
		filter = all
		ai_target_filter = realm_owned
		# is_high_prio = yes
		ai = no
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 3
			is_inaccessible_or_incapable_guilds_trigger = yes
		}
		
		potential = {
			location = { owner = { NOT = { character = FROM } } }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			owner = {
				OR = {
					is_foe = FROM
					AND = { 
						war_with = FROM
						OR = { 
							is_primary_war_attacker = yes
							is_primary_war_defender = yes
						}
					}
				}
			}
			owner = { NOT = { society_member_of = the_guilds } }
			FROM = { scaled_wealth = 0.5 }
			FROM = { society_currency >= 200 }
			location = { NOT = { has_province_modifier = guilds_sabotage_propaganda } }
		}
		
		effect = {
			owner = {
				any_demesne_province = {
					add_province_modifier = {
						name = guilds_sabotage_propaganda
						months = 12
					}
				}
			}
			FROM = { scaled_wealth = -0.5 }
			FROM = { detract_society_currency_minor_effect = yes }
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	guilds_sabotaging_scorched = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		ai_check_interval = 3
		#only_rulers = yes
		from_potential = {
			society_member_of = the_guilds
			society_rank >= 3
			is_inaccessible_or_incapable_guilds_trigger = yes
		}
		
		potential = {
			location = { owner = { character = FROM } }
			OR = {
			holding_type = tribal
			holding_type = temple
			holding_type = castle
			holding_type = city
			holding_type = nomad
			}
		}
		allow = {
			location = { owner = { character = FROM } }
			FROM = { society_currency >= 200 }
			has_siege = yes
			location = { NOT = { has_province_modifier = guilds_sabotage_scorched } }
		}
		
		effect = {
			FROM = { detract_society_currency_minor_effect = yes }
			location = {
				add_province_modifier = {
					name = guilds_sabotage_scorched
					months = 12
				}
				add_province_modifier = {
					name = guilds_sabotage_recovering
					months = 24
				}
			}
			hidden_tooltip = {
				location = {
					if = {
						limit = {
							has_province_modifier = guilds_buff_stone
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_stone }
						}
						remove_province_modifier = guilds_buff_stone
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_steel
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_steel }
						}
						remove_province_modifier = guilds_buff_steel
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_gem
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_gem }
						}
						remove_province_modifier = guilds_buff_gem
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_silver
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_silver }
						}
						remove_province_modifier = guilds_buff_silver
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_gold
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_gold }
						}
						remove_province_modifier = guilds_buff_gold
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_grain
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_grain }
						}
						remove_province_modifier = guilds_buff_grain
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_lumber
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_lumber }
						}
						remove_province_modifier = guilds_buff_lumber
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_linen
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_linen }
						}
						remove_province_modifier = guilds_buff_linen
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_incense
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_incense }
						}
						remove_province_modifier = guilds_buff_incense
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_spices
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_spices }
						}
						remove_province_modifier = guilds_buff_spices
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_meat
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_meat }
						}
						remove_province_modifier = guilds_buff_meat
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_wool
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_wool }
						}
						remove_province_modifier = guilds_buff_wool
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_hide
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_hide }
						}
						remove_province_modifier = guilds_buff_hide
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_ivory
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_ivory }
						}
						remove_province_modifier = guilds_buff_stone
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_silk
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_silk }
						}
						remove_province_modifier = guilds_buff_silk
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_pottery
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_pottery }
						}
						remove_province_modifier = guilds_buff_pottery
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_alcohol
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_alcohol }
						}
						remove_province_modifier = guilds_buff_alcohol
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_armor
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_armor }
						}
						remove_province_modifier = guilds_buff_armor
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_jewelry
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_jewelry }
						}
						remove_province_modifier = guilds_buff_jewelry
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_book
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_book }
						}
						remove_province_modifier = guilds_buff_book
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_glassware
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_glassware }
						}
						remove_province_modifier = guilds_buff_glassware
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_dye
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_dye }
						}
						remove_province_modifier = guilds_buff_dye
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_velvet
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_velvet }
						}
						remove_province_modifier = guilds_buff_velvet
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_fur
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_fur }
						}
						remove_province_modifier = guilds_buff_fur
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_statue
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_statue }
						}
						remove_province_modifier = guilds_buff_statue
					}
					if = {
						limit = {
							has_province_modifier = guilds_buff_music
						}
						random = {
							chance = 33
							FROM = { add_artifact = guilds_item_music }
						}
						remove_province_modifier = guilds_buff_music
					}
				}
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
#warehouse stuff
	guilds_discard_warehouse_province = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 18
		ai = no
		from_potential = {
		}
		potential = {
			owner = { character = FROM }
			OR = {
				has_building = guilds_warehouse_1_city
				has_building = guilds_warehouse_1_castle
				has_building = guilds_warehouse_1_temple
				has_building = guilds_warehouse_1_tribal
				has_building = guilds_warehouse_1_nomad
			}
			NOR = {
				has_building = guilds_warehouse_2_city
				has_building = guilds_warehouse_2_castle
				has_building = guilds_warehouse_2_temple
				has_building = guilds_warehouse_2_tribal
				has_building = guilds_warehouse_2_nomad
				has_building = guilds_warehouse_3_city
				has_building = guilds_warehouse_3_castle
				has_building = guilds_warehouse_3_temple
				has_building = guilds_warehouse_3_tribal
				has_building = guilds_warehouse_3_nomad
			}
		}
		allow = {
		}
		effect = {
			trigger_switch = {
				on_trigger = holding_type
				city = { remove_building = guilds_warehouse_1_city }
				castle = { remove_building = guilds_warehouse_1_castle }
				temple = { remove_building = guilds_warehouse_1_temple }
				tribal = { remove_building = guilds_warehouse_1_tribal }
				nomad = { remove_building = guilds_warehouse_1_nomad }
			}
			# remove_building = guilds_warehouse_1_city
			# remove_building = guilds_warehouse_1_castle
			# remove_building = guilds_warehouse_1_temple
			# remove_building = guilds_warehouse_1_tribal
			# remove_building = guilds_warehouse_1_nomad
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0
		}
	}
	guilds_discard_guards_province = {
		filter = owned
		ai_target_filter = owned
		# is_high_prio = yes
		# ai_check_interval = 18
		ai = no
		from_potential = {
		}
		potential = {
			owner = { character = FROM }
			OR = {
				has_building = guilds_warehouse_3_city
				has_building = guilds_warehouse_3_castle
				has_building = guilds_warehouse_3_temple
				has_building = guilds_warehouse_3_tribal
				has_building = guilds_warehouse_3_nomad
			}
		}
		allow = {
		}
		effect = {
			trigger_switch = {
				on_trigger = holding_type
				city = { remove_building = guilds_warehouse_3_city }
				castle = { remove_building = guilds_warehouse_3_castle }
				temple = { remove_building = guilds_warehouse_3_temple }
				tribal = { remove_building = guilds_warehouse_3_tribal }
				nomad = { remove_building = guilds_warehouse_3_nomad }
			}
			# remove_building = guilds_warehouse_1_city
			# remove_building = guilds_warehouse_1_castle
			# remove_building = guilds_warehouse_1_temple
			# remove_building = guilds_warehouse_1_tribal
			# remove_building = guilds_warehouse_1_nomad
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0
		}
	}
}

title_decisions = {
	guilds_move_resource = {
		ai = no
		filter = owned
		
		from_potential = {
			is_nomadic = yes
		}
		potential = {
			tier = COUNT
			OR = {
				location = {
					NOT = { num_of_settlements = 1 }
				}
				location = {
					capital_holding = {
						NOT = {
							holding_type = nomad
						}
					}
				}
			}
			holder_scope = {
				character = FROM
			}
		}
		allow = {
			has_siege = no
			# location = {
				# capital_holding = {
					# NOR = {
						# holding_type = tribal
						# holding_type = temple
						# holding_type = castle
						# holding_type = city
						# holding_type = nomad
					# }
				# }
			# }
			custom_tooltip = {
				text = guilds_move_resource_no_search_tt
				FROM = { NOT = { has_character_flag = guilds_resource_flag_herd } }
			}
			custom_tooltip = {
				text = guilds_has_nomad_resource
				location = {
					OR = {
						has_province_modifier = guilds_res_meat
						has_province_modifier = guilds_res_wool
						has_province_modifier = guilds_res_hide
						has_province_modifier = guilds_res_ivory
					}
				}
			}
			custom_tooltip = {
				text = guilds_has_no_resource
				FROM = {
					any_demesne_province = {
						capital_holding = {
							holding_type = nomad
						}
						NOR = {
							has_province_modifier = guilds_res_stone
							has_province_modifier = guilds_res_steel
							has_province_modifier = guilds_res_gem
							has_province_modifier = guilds_res_silver
							has_province_modifier = guilds_res_gold
							has_province_modifier = guilds_res_grain
							has_province_modifier = guilds_res_lumber
							has_province_modifier = guilds_res_linen
							has_province_modifier = guilds_res_incense
							has_province_modifier = guilds_res_spices
							has_province_modifier = guilds_res_meat
							has_province_modifier = guilds_res_wool
							has_province_modifier = guilds_res_hide
							has_province_modifier = guilds_res_ivory
							has_province_modifier = guilds_res_silk
						}
					}
				}
			}
		}
		effect = {
			hidden_tooltip = {
				if = {
					limit = {
						location = { has_province_modifier = guilds_res_meat }
					}
					location = { remove_province_modifier = guilds_res_meat }
					FROM = {
						any_demesne_province = {
							limit = {
								capital_holding = {
									holding_type = nomad
								}
							}
							add_province_modifier = {
								name = guilds_res_meat
								duration = -1
								hidden = yes
							}
							province_event = { id = SNW.391 }
						}
					}
				}
				else_if = {
					limit = {
						location = { has_province_modifier = guilds_res_wool }
					}
					location = { remove_province_modifier = guilds_res_wool }
					FROM = {
						any_demesne_province = {
							limit = {
								capital_holding = {
									holding_type = nomad
								}
							}
							add_province_modifier = {
								name = guilds_res_wool
								duration = -1
								hidden = yes
							}
							province_event = { id = SNW.391 }
						}
					}
				}
				else_if = {
					limit = {
						location = { has_province_modifier = guilds_res_hide }
					}
					location = { remove_province_modifier = guilds_res_hide }
					FROM = {
						any_demesne_province = {
							limit = {
								capital_holding = {
									holding_type = nomad
								}
							}
							add_province_modifier = {
								name = guilds_res_hide
								duration = -1
								hidden = yes
							}
							province_event = { id = SNW.391 }
						}
					}
				}
				else_if = {
					limit = {
						location = { has_province_modifier = guilds_res_ivory }
					}
					location = { remove_province_modifier = guilds_res_ivory }
					FROM = {
						any_demesne_province = {
							limit = {
								capital_holding = {
									holding_type = nomad
								}
							}
							add_province_modifier = {
								name = guilds_res_ivory
								duration = -1
								hidden = yes
							}
							province_event = { id = SNW.391 }
						}
					}
				}
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
}