# Only doing bombardment policies for now, mods require an ID variable to be supported.
# Example: @has_my_mod = 1

orbital_bombardment = {
	potential = {
		OR = {
			merg_is_default_empire = yes
			is_country_type = vol
		}
	}

	option = {
		name = "orbital_bombardment_selective"

		policy_flags = {
			orbital_bombardment_selective
		}

		AI_weight = {
			modifier = {
				factor = 0
				NOR = {
					is_pacifist = yes
					# Ethics and Civics Classic
					inline_script = {
						script = merger_of_rules/toggled_code
						code = "
							is_green = yes
						"
						toggle = @has_ecc_cog
					}
					# Ethics & Civics: Bug Branch
					inline_script = {
						script = merger_of_rules/toggled_code
						code = "
							is_ecocentric = yes
						"
						toggle = @has_bug_branch
					}
				}
				NAND = {
					is_galactic_community_member = yes
					OR = {
						is_active_resolution = "resolution_rulesofwar_independent_tribunals"
						is_active_resolution = "resolution_rulesofwar_last_resort_doctrine"
						is_active_resolution = "resolution_rulesofwar_demobilization_initiative"
					}
				}
			}
		}
	}
	option = {
		name = "orbital_bombardment_indiscriminate"

		in_breach_of = {
			{ key = resolution_rulesofwar_independent_tribunals }
			{ key = resolution_rulesofwar_last_resort_doctrine }
			{ key = resolution_rulesofwar_demobilization_initiative }
		}

		policy_flags = {
			orbital_bombardment_indiscriminate
		}
		modifier = {}

		valid = {
			NOR = {
				is_pacifist = yes
				# Ethics and Civics Alternative - Redux
				inline_script = {
					script = merger_of_rules/toggled_code
					code = "
						has_valid_civic = civic_xeno_militarist
					"
					toggle = @has_eca_funefork
				}
				# Ethics & Civics: Bug Branch
				inline_script = {
					script = merger_of_rules/toggled_code
					code = "
						is_bugged_interventionalist = yes
					"
					toggle = @has_bug_branch
				}
				# Expanded Gestalts
				inline_script = {
					script = merger_of_rules/toggled_code
					code = "
						has_valid_civic = civic_mutualistic_behavior
					"
					toggle = @has_forgotten_queens
				}
			}
		}
		AI_weight = {
			modifier = {
				factor = 0.1
				is_galactic_community_member = yes
				OR = {
					is_active_resolution = "resolution_rulesofwar_independent_tribunals"
					is_active_resolution = "resolution_rulesofwar_last_resort_doctrine"
					is_active_resolution = "resolution_rulesofwar_demobilization_initiative"
				}
			}
		}
	}
	# Powerful & Realistic Orbital Bombardments
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			option = {
				name = orbital_bombardment_full
				policy_flags = { orbital_bombardment_indiscriminate orbital_bombardment_full }
				potential = {
					prob_forced_armageddon_bombardment = no
					OR = {
						has_country_flag = prob_enable_full_bombardment
						AND = {
							is_pacifist = no
							OR = {
								is_gestalt = yes
								is_militarist = yes
								is_xenophobe = yes
								has_tradition = tr_supremacy_finish # tr_supremacy_adopt
								AND = { has_ascension_perk = ap_become_the_crisis has_menace_perk = menp_death_from_above }
							}
						}
					}
				}
				valid = { is_pacifist = no }
				AI_weight = {
					weight = 3
					modifier = { factor = 0.1
						is_galactic_community_member = yes
						OR = { is_active_resolution = resolution_galacticstudies_ethical_guideline_refactoring is_active_resolution = resolution_galacticstudies_extradimensional_experimentation }
					}
				}
			}
		"
		toggle = @has_prob_mod
	}
	# Vanilla
	option = {
		name = "orbital_bombardment_armageddon"

		in_breach_of = {
			{ key = resolution_rulesofwar_independent_tribunals }
			{ key = resolution_rulesofwar_last_resort_doctrine }
			{ key = resolution_rulesofwar_demobilization_initiative }
		}

		potential = {
			OR = {
				has_valid_civic = civic_fanatic_purifiers
				has_valid_civic = civic_machine_terminator
				# EMEX
				inline_script = {
					script = merger_of_rules/toggled_code
					code = "
						has_valid_civic = civic_bringers_of_death
						has_valid_civic = civic_machine_destructive_programming
					"
					toggle = @has_emex_mod
				}
				# ZOFE
				inline_script = {
					script = merger_of_rules/toggled_code
					code = "
						is_country_type = ascended_empire
					"
					toggle = @has_zofe_vanilla
				}
			}
		}

		policy_flags = {
			orbital_bombardment_armageddon
		}
		modifier = {}

		AI_weight = {
			modifier = {
				factor = 10
				OR = {
					has_valid_civic = civic_fanatic_purifiers
					has_valid_civic = civic_machine_terminator
					# EMEX
					inline_script = {
						script = merger_of_rules/toggled_code
						code = "
							has_valid_civic = civic_bringers_of_death
						"
						toggle = @has_emex_mod
					}
					# ZOFE
					inline_script = {
						script = merger_of_rules/toggled_code
						code = "
							has_valid_civic = civic_galactic_superpower
						"
						toggle = @has_zofe_vanilla
					}
				}
			}
			modifier = {
				factor = 10
				has_ascension_perk = ap_become_the_crisis
			}
		}
	}
	# Gigastructural Engineering & More
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			option = {
				name = orbital_bombardment_redtoxin
				in_breach_of = {
					{ key = resolution_rulesofwar_independent_tribunals }
					{ key = resolution_rulesofwar_last_resort_doctrine }
					{ key = resolution_rulesofwar_demobilization_initiative }
				}
				potential = {
					OR = {
						merg_is_default_empire = yes
						is_country_type = vol
					}
				}
				prerequisites = {
					tech_scourge_deployment
				}
				policy_flags = {
					orbital_bombardment_redtoxin
				}
				valid = {
					NOR = {
						is_pacifist = yes
						# Ethics and Civics Classic
						inline_script = {
							script = merger_of_rules/toggled_code
							code = \"
								is_green = yes
							\"
							toggle = @has_ecc_cog
						}
						# Ethics & Civics: Bug Branch
						inline_script = {
							script = merger_of_rules/toggled_code
							code = \"
								is_ecocentric = yes
							\"
							toggle = @has_bug_branch
						}
					}
				}
				AI_weight = {
					modifier = {
						factor = 10
						OR = {
							has_valid_civic = civic_fanatic_purifiers
							has_valid_civic = civic_machine_terminator
						}
					}
					modifier = {
						factor = 9
						has_ascension_perk = ap_become_the_crisis
					}
				}
			}
		"
		toggle = @has_gigastructures
	}
	# Origin Beings
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			option = {
				name = orbital_bombardment_infernal

				policy_flags = {
					orbital_bombardment_infernal
				}

				modifier = {}

				potential = {
					has_relic = r_darhmod_infernal
				}

				AI_weight = {
					factor = 1
				}
			}
		"
		toggle = @origin_beings_mod
	}
}

debris = {
	potential = {
		has_encountered_other_species = yes
		OR = {
			merg_is_default_empire = yes
			merg_is_fallen_empire = yes
			merg_is_awakened_fe = yes
		}
	}

	option = {
		name = "research_debris"

		potential = {
			is_scavenger = no
		}

		policy_flags = {
			research_debris
		}
	}
	option = {
		name = "scavenge_debris"

		potential = {
			is_scavenger = no
		}

		policy_flags = {
			scavenge_debris
		}
	}

	option = {
		name = "scavenge_and_research_debris"

		potential = {
			is_scavenger = yes
		}

		policy_flags = {
			scavenge_and_research_debris
		}
	}
}

merger_fake_policy = {
	potential = { always = no }
	allow = { always = no }

	option = {
		name = merg.1.name
		potential = {
			always = no
		}
		policy_flags = {
			hostile_all_gestalts
			gestalt_liberation
			gestalt_punishment
			enemy_gestalt_elimination_forbidden
		}
	}
	option = {
		name = merg.2.name
		potential = {
			always = no
		}
		policy_flags = {
			infiltration_allowed
		}
	}
}
