decisions = {

	
	convert_to_feudalism_indep = {
		is_high_prio = yes
		potential = {
			is_tribal = yes
			independent = yes
		}
		allow = {
				capital_scope = {
					is_tribal = yes
					has_building = tb_hillfort_4
				}
				primary_title = { has_law = tribal_organization_4 }
				prestige = 2000
				scaled_wealth = 0.8
				has_law = crown_authority_1
		}
		effect = {
			prestige = -1500
			scaled_wealth = -0.8
			hidden_tooltip = {
				any_demesne_title = {
					limit = {
						tier = baron
						holding_type = tribal
					}
					convert_to = CASTLE
					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 = city
									}
								}
							}
						}
						location = {
							build_holding = {
								type = city
							}
						}
					}
					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
							}
						}
					}
				}
			}
			
			set_character_flag = achievement_not_a_tribe
			
			if = {
				limit = {
					NOT = { religion_group = muslim }
				}
				
				if = {
					limit = {
						ai = no
					}
					chronicle = {
						entry = CHRONICLE_ADOPTED_FEUDALISM
						picture = GFX_evt_castle_construction
					}
				}
				set_government_type = feudal_government
			}
			
			if = {
				limit = {
					religion_group = muslim
				}
				
				if = {
					limit = {
						ai = no
					}
					chronicle = {
						entry = CHRONICLE_ADOPTED_IQTA
						picture = GFX_evt_castle_construction
					}
				}
				set_government_type = muslim_government
			}
			
			if = {
				limit = {
					higher_tier_than = king
				}
				primary_title = {
					add_law = feudal_administration
				}
			}
		}
		
		ai_will_do = {
			factor = 1
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1 # On average ca 1 year before taken
		}
	}
	
	
	adopt_republicanism = {
		is_high_prio = yes
		potential = {
			is_tribal = yes
			independent = yes
			is_female = no
			OR = {
				ai = yes
				AND = {
					capital_scope = { port = yes }
					has_dlc = "The Republic"
				}
			}
		}
		allow = {
			capital_scope = {
				is_tribal = yes
				has_building = tb_market_town_3
			}
			primary_title = { has_law = tribal_organization_4 }
			scaled_wealth = 1.5
			prestige = 400
		}
		effect = {
			scaled_wealth = -1.5
			prestige = -300
			hidden_tooltip = {
				if = { # create duchy if holder does not have one
					limit = {
						NOT = { higher_tier_than = COUNT }
					}
					primary_title = {
						create_title = {
							tier = DUKE
							landless = no
							temporary = no
							custom_created = yes
							culture = ROOT
							holder = ROOT
							base_title = THIS
						}
					}
				}
				create_family_palace = yes
				any_unique_dynasty_vassal = { # gives random vassals a family palace
					count = 4
					limit = {
						is_female = no
						OR = {
							is_republic = yes
							is_tribal = yes
						}
						prisoner = no
						NOT = { trait = incapable }
						is_adult = yes
						NOT = { 
							dynasty = none 
						}
					}
					create_family_palace = yes
				}
			}
			custom_tooltip = {
				text = adopt_republicanism_tooltip_1
				hidden_tooltip = {
					capital_scope = {
						convert_to_city = yes
						refill_holding_levy = yes
					}
				}
			}
			set_character_flag = achievement_res_publica
			if = {
				limit = {
					ai = no
				}
				chronicle = {
					entry = CHRONICLE_FOUNDED_MERCHANT_REPUBLIC
					picture = GFX_evt_busy_trading_dock_republic
				}
			}
			hidden_tooltip = {
				any_demesne_title = {
					if = {
						limit = {
							is_crown_law_title = yes
						}
						add_law = crown_authority_0
					}
				}
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0.5 # On average ca 1 year before taken
			modifier = {
				factor = 2.0
				stewardship = 10
			}
			modifier = {
				factor = 2.0
				is_republic = yes
			}
		}
	}
}
	


