core_with_compliance = {
	
	cwc_add_core = {
		icon = generic_prepare_civil_war
		
		cost = 50

		available = {
			has_core_occupation_modifier = {
				occupied_country_tag = FROM
				modifier = compliance_80
			}
		}
        visible = {
			has_core_occupation_modifier = {
				occupied_country_tag = FROM
				modifier = compliance_60
			}
        }

		complete_effect = {
			every_state = {
				limit = {
					is_core_of = FROM
					is_owned_by = ROOT
				}
				ROOT = {
					add_state_core = PREV
				}
			}
		}
		
		target_non_existing = yes
		target_array = occupied_countries
		
		
		ai_will_do = {
			base = 0
			
			
			
			
			
		}
	}
	
	cwc_instantiate_collaboration = {
		icon = generic_prepare_civil_war

		cost = 0

		available = {
			has_core_occupation_modifier = {
				occupied_country_tag = FROM
				modifier = compliance_80
			}
		}
        visible = {
			#has_rule = can_create_collaboration_government
			#is_available_to_collaboration_government = yes
			has_core_occupation_modifier = {
				occupied_country_tag = FROM
				modifier = compliance_60
			}
        }

		complete_effect = {
			set_temp_variable = { country_to_initiate = FROM }
			instantiate_collaboration_government = yes
		}

		target_non_existing = yes
		target_array = occupied_countries


		ai_will_do = {
			base = 10
			# priotize larger countries

			modifier = {
				# blocks our focus tree for libyan oil
				tag = ITA
				FROM = {
					tag = LBA
				}

				factor = 0
			}
			modifier = {
			# we dont want japan doing this and its not covered by the below size checks
				tag = JAP
				FROM = { tag = GUM }

				factor = 0
			}
			modifier = {
			# feels wierd to generate random ppl here over the nazis running the show and hoi doesnt have those except perhaps Von Neurath, but he didnt really run things past 41 so best just block it from ai while at war honestly.
				tag = GER
				FROM = { tag = CZE }
				has_war = yes

				factor = 0
			}

			modifier = {
				# neutrals won't do collaboration until 1944 and they are at peace

				has_government = neutrality
				# allow neutral GER
				not = { tag = GER }

				OR = {
					has_war = yes
					date < 1944.01.01
				}

				factor = 0
			}

			modifier = {
				# calculating cores we control
				set_temp_variable = { num_cores_we_control = 0 }
				all_of_scopes = {
					array = FROM.core_states

					if = {
						limit = { is_controlled_by = PREV }
						add_to_temp_variable = { num_cores_we_control = 1 }
					}
				}

				# more score if more cores are controlled by us
				add = num_cores_we_control
			}

			# dont make too many collaboratios
			modifier = {
				# as number of collaboration subjects increases
				# only accept subjects with more cores
				set_temp_variable = { num_min_cores = 1.5 }
				all_of_scopes = {
					array = subjects
					if = {
						limit = {
							has_autonomy_state = autonomy_collaboration_government
						}
						add_to_temp_variable = { num_min_cores = 0.7 }
					}
				}

				check_variable = { num_cores_we_control < num_min_cores }

				factor = 0
			}

			modifier = {
			# [softly] Don't...
				tag = TUR
				FROM = { tag = KUR }

				factor = 0
			}
			modifier = {
				FROM = {
					tag = POL
					is_ai = no
				}

				factor = 0
			}
			# don't create collab governments if you have contested cores
			modifier = {
				any_state = {
					OR = {
						is_controlled_by = ROOT
						is_owned_by = ROOT
					}
					is_core_of = FROM
					is_core_of = ROOT
				}
				factor = 0
			}
		}
	}
}

