resolution_voidworm_eradication = {
	icon = "GFX_resolution_voidworm_eradication"

	resources = {
		category = resolutions
		cost = {
			influence = @resolution_cost_denounce
		}
	}
	target = no

	effect = {
		custom_tooltip = resolution_voidworm_eradication_tooltip
		hidden_effect = {
			set_global_flag = resolution_with_breach_effect_passed
			set_global_flag = galactic_community_resolution_passed
			country_event = { id = grand_archive.2102 }
			set_timed_country_flag = { flag = galactic_community_resolution_passed_general days = @resolution_flag_timer }
			add_modifier = {
				modifier = resolution_passed_diplomatic_weight
				days = 2200
			}
		}
	}

	fail_effects = {
		hidden_effect = {
			set_timed_country_flag = { flag = galactic_community_resolution_failed_general days = @resolution_flag_timer }
			add_modifier = {
				modifier = resolution_failed_diplomatic_weight
				days = 2200
			}
		}
	}

	potential = {
		has_federations_dlc = yes
		has_grand_archive_dlc = yes
		NOT = { has_global_flag = voidworms_extinct }
	}

	allow = {
		custom_tooltip = {
			fail_text = "resolution_already_active"
			NOT = { is_active_resolution = "resolution_voidworm_eradication" }
		}
	}

	active = { # Resolution only in effect while this trigger is met
		count_system = {
			limit = { has_star_flag = voidworms_system }
			count > 0
		}
	}

	breach = {
		has_country_flag = resolution_breached_voidworms_inside_borders
		NOT = { has_country_flag = constitutional_immunity }
	}

	ai_weight = {
		base = @resolution_weight_disliked

		modifier = {
			factor = 2
			is_xenophobe = yes
			desc = ethic_xenophobe
		}

		modifier = {
			factor = 1.25
			is_militarist = yes
			desc = ethic_militarist
		}

		modifier = {
			factor = 1.5
			has_valid_civic = civic_hive_cordyceptic_drones
			desc = gal_com_supporting_civics
		}

		modifier = {
			factor = 0.5
			OR = {
				has_valid_civic = civic_environmentalist
				has_valid_civic = civic_hive_empath
			}
			desc = gal_com_opposing_civics
		}

		modifier = {
			factor = 0.5
			is_pacifist = yes
			desc = ethic_pacifist
		}

		modifier = {
			factor = 0.5
			is_xenophile = yes
			desc = ethic_xenophile
		}

		modifier = {
			factor = 0.5
			has_origin = origin_fruitful
			desc = gal_com_opposing_origin
		}
	}
}

resolution_repeal_voidworm_eradication = {
	icon = "GFX_repeal_red"

	resources = {
		category = resolutions
		cost = {
			influence = @resolution_cost_denounce
		}
	}

	target = no
	fire_and_forget = yes

	effect = {
		custom_tooltip = resolution_repeal_voidworm_eradication_effect_success
		hidden_effect = {
			cancel_resolution = "resolution_voidworm_eradication"
			set_timed_country_flag = { flag = galactic_community_resolution_passed_ecology_repeal days = @resolution_flag_timer }
			add_modifier = {
				modifier = resolution_passed_diplomatic_weight
				days = 2200
			}
		}
	}

	fail_effects = {
		hidden_effect = {
			set_timed_country_flag = { flag = galactic_community_resolution_failed_ecology_repeal days = @resolution_flag_timer }
			add_modifier = {
				modifier = resolution_failed_diplomatic_weight
				days = 2200
			}
		}
	}

	potential = {
		is_active_resolution = "resolution_voidworm_eradication"
	}

	ai_weight = {
		base = @resolution_weight_disliked

		modifier = {
			factor = 2
			has_origin = origin_fruitful
			desc = gal_com_supporting_origin
		}

		modifier = {
			factor = 1.5
			is_xenophile = yes
			desc = ethic_xenophile
		}

		modifier = {
			factor = 1.25
			is_pacifist = yes
			desc = ethic_pacifist
		}

		modifier = {
			factor = 0.75
			is_militarist = yes
			desc = ethic_militarist
		}

		modifier = {
			factor = 1.5
			OR = {
				has_valid_civic = civic_environmentalist
				has_valid_civic = civic_hive_empath
			}
			desc = gal_com_supporting_civics
		}

		modifier = {
			factor = 0
			has_valid_civic = civic_hive_cordyceptic_drones
			desc = gal_com_opposing_civics
		}

		modifier = {
			factor = 0
			is_xenophobe = yes
			desc = ethic_xenophobe
		}

		modifier = {
			factor = 10
			in_breach_of = resolution_voidworm_eradication
			desc = gal_com_in_breach_of_proposed_resolution
		}
	}
}

resolution_cutholoid_eradication = {
	icon = "GFX_resolution_cutholoid_eradication"

	resources = {
		category = resolutions
		cost = {
			influence = @resolution_cost_denounce
		}
	}
	target = no

	effect = {
		custom_tooltip = resolution_cutholoid_eradication_tooltip
		hidden_effect = {
			set_global_flag = resolution_with_breach_effect_passed
			set_global_flag = galactic_community_resolution_passed
			country_event = { id = grand_archive.3102 }
			set_timed_country_flag = { flag = galactic_community_resolution_passed_general days = @resolution_flag_timer }
			add_modifier = {
				modifier = resolution_passed_diplomatic_weight
				days = 2200
			}
		}
	}

	fail_effects = {
		hidden_effect = {
			set_timed_country_flag = { flag = galactic_community_resolution_failed_general days = @resolution_flag_timer }
			add_modifier = {
				modifier = resolution_failed_diplomatic_weight
				days = 2200
			}
		}
	}

	potential = {
		has_federations_dlc = yes
		has_grand_archive_dlc = yes
		exists = event_target:cutholoids_country
		any_country = {
			has_established_contact = event_target:cutholoids_country
		}
	}

	allow = {
		custom_tooltip = {
			fail_text = "resolution_already_active"
			NOT = { is_active_resolution = "resolution_cutholoid_eradication" }
		}
	}

	active = { # Resolution only in effect while this trigger is met
		always = yes
	}

	breach = {
		NOT = { has_country_flag = constitutional_immunity }
		has_country_flag = resolution_breached_cutholoids_inside_borders
	}

	ai_weight = {
		base = @resolution_weight_disliked

		modifier = {
			factor = 2
			is_xenophobe = yes
			desc = ethic_xenophobe
		}

		modifier = {
			factor = 0.5
			is_pacifist = yes
			desc = ethic_pacifist
		}

		modifier = {
			factor = 1.25
			is_militarist = yes
			desc = ethic_militarist
		}

		modifier = {
			factor = 0.5
			OR = {
				has_valid_civic = civic_environmentalist
				has_valid_civic = civic_hive_empath
			}
			desc = gal_com_opposing_civics
		}

		modifier = {
			factor = 1.5
			has_valid_civic = civic_hive_cordyceptic_drones
			desc = gal_com_supporting_civics
		}

		modifier = {
			factor = 0
			is_xenophile = yes
			desc = ethic_xenophile
		}

		modifier = {
			factor = 0
			has_origin = origin_fruitful
			desc = gal_com_opposing_origin
		}
	}
}

resolution_repeal_cutholoid_eradication = {
	icon = "GFX_repeal_red"

	resources = {
		category = resolutions
		cost = {
			influence = @resolution_cost_denounce
		}
	}

	target = no
	fire_and_forget = yes

	effect = {
		custom_tooltip = resolution_repeal_cutholoid_eradication_effect_success
		hidden_effect = {
			cancel_resolution = "resolution_cutholoid_eradication"
			set_timed_country_flag = { flag = galactic_community_resolution_passed_ecology_repeal days = @resolution_flag_timer }
			add_modifier = {
				modifier = resolution_passed_diplomatic_weight
				days = 2200
			}
		}
	}

	fail_effects = {
		hidden_effect = {
			set_timed_country_flag = { flag = galactic_community_resolution_failed_ecology_repeal days = @resolution_flag_timer }
			add_modifier = {
				modifier = resolution_failed_diplomatic_weight
				days = 2200
			}
		}
	}

	potential = {
		is_active_resolution = "resolution_cutholoid_eradication"
	}

	ai_weight = {
		base = @resolution_weight_disliked

		modifier = {
			factor = 2
			has_origin = origin_fruitful
			desc = gal_com_supporting_origin
		}

		modifier = {
			factor = 1.5
			is_xenophile = yes
			desc = ethic_xenophile
		}

		modifier = {
			factor = 1.25
			is_pacifist = yes
			desc = ethic_pacifist
		}

		modifier = {
			factor = 0.75
			is_militarist = yes
			desc = ethic_militarist
		}

		modifier = {
			factor = 1.5
			OR = {
				has_valid_civic = civic_environmentalist
				has_valid_civic = civic_hive_empath
			}
			desc = gal_com_supporting_civics
		}

		modifier = {
			factor = 0
			has_valid_civic = civic_hive_cordyceptic_drones
			desc = gal_com_opposing_civics
		}

		modifier = {
			factor = 0
			is_xenophobe = yes
			desc = ethic_xenophobe
		}

		modifier = {
			factor = 10
			in_breach_of = resolution_cutholoid_eradication
			desc = gal_com_in_breach_of_proposed_resolution
		}
	}
}

resolution_galactic_focus_crisis_voidworm_plague = {
	icon = "GFX_resolution_emergency_measure"

	resources = {
		category = resolutions
		cost = {
			influence = @resolution_cost_t1
		}
	}

	target = no

	effect = {
		custom_tooltip = resolution_galactic_focus_crisis_voidworm_plague_effect_success

		hidden_effect = {
			repeal_all_galactic_focus_resolutions = yes
			set_global_flag = galactic_focus_crisis_voidworm_plague
			set_global_flag = galactic_community_crisis_fighting

			set_global_flag = galactic_community_resolution_passed

			set_timed_country_flag = { flag = galactic_community_resolution_passed_general days = @resolution_flag_timer }
			add_modifier = {
				modifier = resolution_passed_diplomatic_weight
				days = 2200
			}
		}
	}

	fail_effects = {
		hidden_effect = {
			set_timed_country_flag = { flag = galactic_community_resolution_failed_general days = @resolution_flag_timer }
			add_modifier = {
				modifier = resolution_failed_diplomatic_weight
				days = 2200
			}
		}
	}

	potential = {
		has_grand_archive_dlc = yes
		is_voidworms_crisis_active = yes
		NOT = { has_global_flag = galactic_focus_crisis_voidworm_plague }
	}

	active = { # Resolution only in effect while this trigger is met
		is_voidworms_crisis_active = yes
	}

	ai_weight = {
		base = @resolution_weight_normal

		modifier = {
			factor = 2

			check_variable = {
				which = voidworm_plague_pop_victims_count
				value >= @galactic_focus_crisis_voidworm_pop_victims_threshold
			}
			desc = gal_com_crisis_voidworm_pop_victims
		}

		modifier = {
			factor = 1.2
			is_machine_empire = yes
			desc = auth_machine_intelligence
		}

		modifier = {
			factor = 1.2
			is_militarist = yes
			desc = ethic_militarist
		}

		modifier = {
			factor = 1.2
			is_xenophile = yes
			desc = ethic_xenophile
		}

		# ------------------------------------------------------------------
		# All civic version has an entry so the correct name is used
		modifier = {
			factor = 0.9
			has_valid_civic = civic_beastmasters
			desc = civic_beastmasters
		}

		modifier = {
			factor = 0.9
			has_valid_civic = civic_hive_beastmasters
			desc = civic_hive_beastmasters
		}

		modifier = {
			factor = 0.9
			has_valid_civic = civic_machine_beastmasters
			desc = civic_machine_beastmasters
		}

		modifier = {
			factor = 0.9
			has_valid_civic = civic_corporate_beastmasters
			desc = civic_corporate_beastmasters
		}
		# ------------------------------------------------------------------

		modifier = {
			factor = 0.5
			is_xenophobe = yes
			desc = ethic_xenophobe
		}
	}
}
