
prospect_for_resources = {
	eeu_decision_drill_enable = {
		icon = oil

		target_array = global.eeu_array_offshore_countries
		target_non_existing = yes

		visible = {
			has_country_flag = EEU_flag_unlock_offshore
		}

		target_trigger = {
			FROM = {
				NOT = {
					has_country_flag = eeu_flag_drilling_enabled
				}
				capital_scope = {
					is_controlled_by = ROOT
				}
			}
		}

		complete_effect = {
			FROM = {
				set_country_flag = eeu_flag_drilling_enabled
			}
		}
	}

	eeu_decision_drill_disable = {
		icon = oil
		target_array = global.eeu_array_offshore_countries
		target_non_existing = yes

		visible = {
			has_country_flag = EEU_flag_unlock_offshore
		}

		target_trigger = {
			FROM = {
				has_country_flag = eeu_flag_drilling_enabled
			}
		}

		complete_effect = {
			FROM = {
				clr_country_flag = eeu_flag_drilling_enabled
			}
		}
	}


	eeu_decision_drill_oil = {
		icon = oil

		target_array = controlled_states
		state_target = yes

		visible = {
			has_country_flag = EEU_flag_unlock_offshore
		}
		target_trigger = {
			FROM = {
				OR = {
					has_state_flag = eeu_flag_drill_in_progress
					AND = {
						is_coastal = yes
						any_of_scopes = {
							array = global.eeu_array_offshore_countries
							PREV = {
								is_core_of = PREV
							}
							has_country_flag = eeu_flag_drilling_enabled
						}
						OR = {
							NOT = {
								has_variable = eeu_var_state_drill_counter
							}
							check_variable = {
								eeu_var_state_drill_counter < 3
							}
						}
						num_owned_neighbour_states = {
							owner = ROOT
							count < 3
						}
					}
				}
			}
		}

		cost = 25
		days_remove = 60
		days_re_enable = 0

		available = {
			num_of_civilian_factories_available_for_projects > 9
			if = {
				limit = {
					check_variable = {
						FROM.eeu_var_state_drill_counter = 0
					}
				}
				has_tech = excavation2
			}
			else_if = {
				limit = {
					check_variable = {
						FROM.eeu_var_state_drill_counter = 1
					}
				}
				has_tech = excavation3
			}
			if = {
				limit = {
					check_variable = {
						FROM.eeu_var_state_drill_counter = 2
					}
				}
				has_tech = excavation4
			}
		}

		modifier = {
			civilian_factory_use = 10
		}

		complete_effect = {
			FROM = {
				set_state_flag = eeu_flag_drill_in_progress
			}
			for_each_scope_loop = {
				array = global.eeu_array_offshore_countries
				# if = {
				# 	limit = {
				# 		FROM = {
				# 			is_core_of = PREV
				# 		}
				# 	}
				# }
				clr_country_flag = eeu_flag_drilling_enabled
			}
		}

		remove_effect = {
			FROM = {
				set_temp_variable = {
					eeu_oil_add_temp = 1
				}
				add_to_temp_variable = {
					eeu_oil_add_temp = eeu_var_state_drill_counter
				}
				multiply_temp_variable = {
					eeu_oil_add_temp = 2
				}

				add_resource = {
					type = oil
					amount = var:eeu_oil_add_temp
				}
				
				add_to_variable = {
					eeu_var_state_drill_counter = 1
				}
				clr_state_flag = eeu_flag_drill_in_progress
			}
		}
	}
}