mem_dpe_become_protectorate = {
	hidden_effect = { #Taken from event primitive.16 with slight alterations
		event_target:mem_dpe_primitive_civ = {

			remove_country_flag = early_space_age
			set_country_flag = primitives_can_into_space
			set_country_type = default
			change_country_flag = random
			if = {
				limit = { is_species_class = MAM }
				set_graphical_culture = mammalian_01
			}
			if = {
				limit = { is_species_class = REP }
				set_graphical_culture = reptilian_01
			}
			if = {
				limit = { is_species_class = AVI }
				set_graphical_culture = avian_01
			}
			if = {
				limit = { is_species_class = ART }
				set_graphical_culture = arthropoid_01
			}
			if = {
				limit = { is_species_class = MOL }
				set_graphical_culture = molluscoid_01
			}
			if = {
				limit = { is_species_class = FUN }
				set_graphical_culture = fungoid_01
			}
			if = {
				limit = { is_species_class = PLANT }
				set_graphical_culture = plantoid_01
			}		
			change_government = {
				authority = random
				civics = random
			}
			set_name = random
			add_resource = {
				energy = 500
				minerals = 1000 # enough for a spaceport and then some
			}
			add_resource = { influence = 300 }
			capital_scope = {
				clear_blockers = yes
				while = {
					limit = { 
						pop_amount < 800
						#free_housing > 0
					}
					create_pop_group = {
						species = owner
					}
				}
				remove_building = building_primitive_farm
				remove_building = building_primitive_factory
				remove_building = building_primitive_capital
				remove_building = building_urban_dwellings
				add_district = district_city
				add_district = district_city
				add_district = district_city
				add_district = district_industrial
				add_district = district_industrial
				add_district = district_farming
				add_district = district_farming
				add_district = district_farming
				add_district = district_mining
				add_district = district_mining
				add_district = district_generator
				add_district = district_generator
				add_building = building_capital
				add_building = building_research_lab_1
				add_building = building_foundry_1
				
				remove_all_armies = yes
				solar_system = {
					starbase = {
						set_owner = event_target:mem_dpe_primitive_civ
					}
				}			
			}
			random_controlled_ship = {
				limit = { is_ship_size = primitive_space_station }
				fleet = { destroy_fleet = THIS }
			}
			if = {
				limit = {
					root = { has_valid_civic = "civic_inwards_perfection" }
				}
				set_subject_of = {
					who = root
					preset = preset_tributary
				}
			}			
			else = {
				set_subject_of = {
					who = root
					preset = preset_protectorate
				}						
			}
		}
	}
}
