###################################### Vanilla ######################################
can_destroy_planet_with_PLANET_KILLER_CRACKER = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_standard_planet_or_megastructure
		is_a_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	custom_tooltip = {
		fail_text = fotd_cant_collossus
		NOT = { has_planet_flag = fotd_seperatist_planet@from.owner }
		exists = from.owner
		from.owner = {
			NOT = { has_country_flag = fotd_seperatist_country@from.owner }
		}
	}
	OR = {
		custom_tooltip = {
			text = is_not_hostile_cracker
			OR = {
				AND = {
					exists = space_owner
					space_owner = {
						merg_is_at_war = yes
					}
				}
				AND = {
					# colony
					exists = owner
					owner = {
						merg_is_at_war = yes
					}
				}
				AND = {
					# primitive target
					custom_tooltip = {
						text = cannot_crack_pre_ftl_planet_ownership
						exists = space_owner
						exists = owner
						owner = { is_primitive = yes }
						space_owner = {
							OR = {
								is_same_value = from.owner
								merg_is_at_war = yes
							}
						}
					}
					custom_tooltip = {
						text = cannot_crack_pre_ftl_planet_interference
						# primitive
						exists = owner
						owner = { is_primitive = yes }
						from.owner = { has_policy_flag = interference_aggressive }
					}
				}
			}
		}
		custom_tooltip = {
			text = not_barren_molten_frozen_toxic_test_fire
			NOT = { exists = owner }
			OR = {
				NOT = { exists = space_owner }
				AND = {
					exists = space_owner
					space_owner = { is_same_empire = from.owner }
				}
			}
			merg_is_valid_for_test_fire = yes
		}
	}
}
can_destroy_planet_with_PLANET_KILLER_SHIELDER = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		OR = {
			is_a_habitable_planet_megastructure = yes
			is_planet_class = pc_ai
		}
	}
	custom_tooltip = {
		fail_text = is_not_hostile_or_primitive
		OR = {
			merg_planet_is_hostile_or_crisis = yes
			AND = {
				exists = owner
				owner = { is_country_type = primitive }
			}
		}
	}
	custom_tooltip = {
		fail_text = lathe_cant_colossus
		NOT = { is_planet_class = pc_cosmogenesis_world }
	}
	custom_tooltip = {
		fail_text = fotd_cant_collossus
		NOT = { has_planet_flag = fotd_seperatist_planet@from.owner }
		exists = from.owner
		from.owner = {
			NOT = { has_country_flag = fotd_seperatist_country@from.owner }
		}
	}
	if = {
		limit = {
			exists = owner
			owner = { is_country_type = primitive }
		}
		custom_tooltip = {
			fail_text = primitives_not_full_interference
			from.owner = { has_policy_flag = interference_aggressive }
		}
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
}
can_destroy_planet_with_PLANET_KILLER_NEUTRON = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		OR = {
			AND = {
				merg_has_safety_off = no
				is_a_habitable_planet_megastructure = yes
			}
		}
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	custom_tooltip = {
		fail_text = fotd_cant_collossus
		NOT = { has_planet_flag = fotd_seperatist_planet@from.owner }
		exists = from.owner
		from.owner = {
			NOT = { has_country_flag = fotd_seperatist_country@from.owner }
		}
	}
	custom_tooltip = {
		fail_text = lathe_cant_colossus
		NOT = { is_planet_class = pc_cosmogenesis_world }
	}
	custom_tooltip = {
		fail_text = is_not_hostile
		OR = {
			merg_planet_is_hostile_or_crisis = yes
			AND = {
				exists = owner
				owner = { is_country_type = primitive }
				custom_tooltip = {
					fail_text = primitives_not_full_interference
					from.owner = { has_policy_flag = interference_aggressive }
				}
			}
			AND = {
				# at war with primitive space owner
				exists = space_owner
				exists = owner
				owner = { is_primitive = yes }
				space_owner = {
					merg_is_at_war = yes
				}
			}
		}
	}
	custom_tooltip = {
		fail_text = is_unpopulated
		OR = {
			num_pops > 0
			is_planet_class = pc_infested
			# Expanded Events
			inline_script = {
				script = merger_of_rules/toggled_code
				code = "
					has_modifier = planet_active_worm
				"
				toggle = @expevents_compatch_var
			}
		}
	}
}
can_destroy_planet_with_PLANET_KILLER_GODRAY = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		OR = {
			is_a_habitable_planet_megastructure = yes
			is_planet_class = pc_ai
		}
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	custom_tooltip = {
		fail_text = lathe_cant_colossus
		NOT = { is_planet_class = pc_cosmogenesis_world }
	}
	custom_tooltip = {
		fail_text = fotd_cant_collossus
		NOT = { has_planet_flag = fotd_seperatist_planet@from.owner }
		exists = from.owner
		from.owner = {
			NOT = { has_country_flag = fotd_seperatist_country@from.owner }
		}
	}
	custom_tooltip = {
		#success_text = "is at war with player"
		fail_text = is_not_hostile_or_primitive
		OR = {
			planet_is_hostile = yes
			is_planet_class = pc_ai
			AND = {
				exists = owner
				owner = {
					is_country_type = primitive
				}
			}
			AND = {
				exists = owner
				owner = {
					is_same_empire = from.owner
				}
			}
		}
	}
	if = {
		limit = {
			exists = owner
			owner = {
				is_country_type = primitive
			}
		}
		custom_tooltip = {
			fail_text = primitives_not_full_interference
			from.owner = { has_policy_flag = interference_aggressive }
		}
	}
	# target own colony
	if = {
		limit = {
			NOR = {
				planet_is_hostile = yes
				AND = {
					exists = owner
					owner = { is_country_type = primitive }
				}
			}
			exists = owner
			owner = { is_same_value = from.owner }
		}
		custom_tooltip = {
			text = not_owned_test_fire
			exists = owner
			owner = { is_same_value = from.owner }
		}
	}
}
can_destroy_planet_with_PLANET_KILLER_NANOBOTS = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		is_a_habitable_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	custom_tooltip = {
		fail_text = lathe_cant_colossus
		NOT = { is_planet_class = pc_cosmogenesis_world }
	}
	custom_tooltip = {
		fail_text = fotd_cant_collossus
		NOT = { has_planet_flag = fotd_seperatist_planet@from.owner }
		exists = from.owner
		from.owner = {
			NOT = { has_country_flag = fotd_seperatist_country@from.owner }
		}
	}
	custom_tooltip = {
		fail_text = is_not_hostile_or_primitive
		OR = {
			planet_is_hostile = yes
			AND = {
				exists = owner
				owner = { is_country_type = primitive }
			}
			AND = {
				merg_has_safety_off = yes
				is_same_value = from.owner
			}
		}
	}
	if = {
		limit = {
			exists = owner
			owner = { is_country_type = primitive }
		}
		custom_tooltip = {
			fail_text = primitives_not_in_borders
			exists = space_owner
			space_owner = { is_same_empire = from.owner }
		}
		custom_tooltip = {
			fail_text = primitives_not_full_interference
			from.owner = { has_policy_flag = interference_aggressive }
		}
	}
	custom_tooltip = {
		fail_text = no_assimilatable_pops
		any_owned_pop = {
			is_valid_pop_for_PLANET_KILLER_NANOBOTS = yes
		}
	}
}
can_destroy_planet_with_PLANET_KILLER_DELUGE = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_habitable_non_artificial
		OR = {
			is_colonizable = yes
			is_colony = yes
		}
		is_artificial = no
	}
	custom_tooltip = {
		fail_text = fotd_cant_collossus
		NOT = { has_planet_flag = fotd_seperatist_planet@from.owner }
		exists = from.owner
		from.owner = {
			NOT = { has_country_flag = fotd_seperatist_country@from.owner }
		}
	}
	custom_tooltip = {
		fail_text = lathe_cant_colossus
		NOT = { is_planet_class = pc_cosmogenesis_world }
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	custom_tooltip = {
		fail_text = is_not_oceanic
		merg_is_aquatic = no
	}
	if = {
		limit = { is_inside_border = from.owner }
		if = {
			limit = {
				#Uninhabited and primitive planets are always fine, if own colony then check if pops would be purged
				exists = owner
				owner = { is_same_value = from.owner }
				any_owned_species = {
					NOR = {
						has_trait = trait_aquatic
						has_trait = trait_robot_aquatic
					}
				}
			}
			custom_tooltip = {
				fail_text = requires_purge_allowed
				success_text = will_purge_non_aquatic_pops
				from.owner = {
					is_ai = no
					has_policy_flag = purge_allowed
				}
			}
		}
	}
	else = {
		custom_tooltip = {
			fail_text = is_not_hostile_or_primitive_or_ours
			OR = {
				merg_planet_is_hostile_or_crisis = yes
				AND = {
					exists = owner
					owner = { is_country_type = primitive }
				}
			}
		}
	}
	if = {
		limit = {
			exists = owner
			owner = { is_country_type = primitive }
		}
		custom_tooltip = {
			fail_text = primitives_not_in_borders
			exists = space_owner
			space_owner = { is_same_value = from.owner }
		}
		custom_tooltip = {
			fail_text = primitives_not_full_interference
			from.owner = {
				has_policy_flag = interference_aggressive
			}
		}
	}
}
can_destroy_planet_with_PLANET_KILLER_TOXIFIER = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_habitable_non_artificial
		OR = {
			is_colonizable = yes
			is_colony = yes
		}
		is_artificial = no
	}
	custom_tooltip = {
		fail_text = lathe_cant_colossus
		NOT = { is_planet_class = pc_cosmogenesis_world }
	}
	custom_tooltip = {
		fail_text = fotd_cant_collossus
		NOT = { has_planet_flag = fotd_seperatist_planet@from.owner }
		exists = from.owner
		from.owner = {
			NOT = { has_country_flag = fotd_seperatist_country@from.owner }
		}
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	OR = {
		custom_tooltip = {
			text = is_not_hostile_cracker
			OR = {
				AND = {
					exists = space_owner
					space_owner = {
						merg_is_at_war = yes
					}
				}
				AND = { # colony
					exists = owner
					owner = {
						merg_is_at_war = yes
					}
				}
				AND = { # primitive
					exists = space_owner
					exists = owner
					owner = {
						is_primitive = yes
					}
					space_owner = {
						merg_is_at_war = yes
					}
				}
			}
		}
		custom_tooltip = {
			text = is_not_owned_or_claimed
			NOR = {
				exists = owner
				exists = space_owner
			}
		}
		custom_tooltip = {
			text = is_uninhabited_within_borders
			exists = space_owner
			space_owner = { is_same_value = from.owner }
			is_colony = no
		}
	}
}
can_destroy_planet_with_PLANET_KILLER_DEVOLUTION = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		OR = {
			is_a_habitable_planet_megastructure = yes
			is_planet_class = pc_ai
		}
	}
	custom_tooltip = {
		fail_text = lathe_cant_colossus
		NOT = { is_planet_class = pc_cosmogenesis_world }
	}
	custom_tooltip = {
		fail_text = recently_devolved
		NOT = { has_planet_flag = devolved_planet }
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	custom_tooltip = {
		fail_text = fotd_cant_collossus
		NOT = { has_planet_flag = fotd_seperatist_planet@from.owner }
		exists = from.owner
		from.owner = {
			NOT = { has_country_flag = fotd_seperatist_country@from.owner }
		}
	}
	custom_tooltip = {
		#success_text = "is at war with player"
		fail_text = is_not_hostile_or_primitive
		OR = {
			planet_is_hostile = yes
			is_planet_class = pc_ai
			AND = {
				exists = owner
				owner = { is_country_type = primitive }
			}
		}
	}
	if = {
		limit = {
			exists = owner
			owner = { is_country_type = primitive }
		}
		custom_tooltip = {
			fail_text = primitives_not_full_interference
			from.owner = {
				has_policy_flag = interference_aggressive
			}
		}
	}
}
can_destroy_planet_with_PLANET_KILLER_STAR_CRACKER = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		solar_system = {
			any_system_planet = { merg_is_untargetable = no }
		}
	}
	custom_tooltip = {
		fail_text = is_your_megastructure_system
		NOT = {
			solar_system = {
				has_star_flag = crisis_sphere_system@from.owner
				any_system_megastructure = { has_megastructure_flag = crisis_sphere }
			}
		}
	}
	custom_tooltip = {
		fail_text = is_not_star
		is_star = yes
	}
	custom_tooltip = {
		fail_text = is_black_hole
		exists = system_star
		system_star = { merg_is_black_or_white_hole = no }
	}
	custom_tooltip = {
		fail_text = is_sc_black_hole
		solar_system = { merg_is_hole_star_class = no }
	}
	custom_tooltip = {
		fail_text = star_owner_is_not_hostile
		OR = {
			NOT = { exists = space_owner }
			space_owner = { is_hostile = from.owner }
			space_owner = { is_same_value = from.owner }
		}
	}
}

###################################### Mods start here ######################################

############################### ACOT/AOT ###############################
can_destroy_planet_with_ACOT_PLANET_KILLER_CRACKER = { can_destroy_planet_with_PLANET_KILLER_CRACKER = yes }
can_destroy_planet_with_ACOT_PLANET_KILLER_SHIELDER = { can_destroy_planet_with_PLANET_KILLER_SHIELDER = yes }
can_destroy_planet_with_ACOT_PLANET_KILLER_NEUTRON = { can_destroy_planet_with_PLANET_KILLER_NEUTRON = yes }
can_destroy_planet_with_ACOT_PLANET_KILLER_GODRAY = { can_destroy_planet_with_PLANET_KILLER_GODRAY = yes }
can_destroy_planet_with_ACOT_PLANET_KILLER_NANOBOTS = { can_destroy_planet_with_PLANET_KILLER_NANOBOTS = yes }
can_destroy_planet_with_ACOT_SE_PLANET_KILLER_CRACKER = { can_destroy_planet_with_PLANET_KILLER_CRACKER = yes }
can_destroy_planet_with_ACOT_SE_PLANET_KILLER_SHIELDER = { can_destroy_planet_with_PLANET_KILLER_SHIELDER = yes }
can_destroy_planet_with_ACOT_SE_PLANET_KILLER_NEUTRON = { can_destroy_planet_with_PLANET_KILLER_NEUTRON = yes }
can_destroy_planet_with_ACOT_SE_PLANET_KILLER_GODRAY = { can_destroy_planet_with_PLANET_KILLER_GODRAY = yes }
can_destroy_planet_with_ACOT_SE_PLANET_KILLER_NANOBOTS = { can_destroy_planet_with_PLANET_KILLER_NANOBOTS = yes }
can_destroy_planet_with_ACOT_HE_PLANET_KILLER_CRACKER = { can_destroy_planet_with_PLANET_KILLER_CRACKER = yes }
can_destroy_planet_with_ACOT_HE_PLANET_KILLER_CRACKER = { can_destroy_planet_with_PLANET_KILLER_CRACKER = yes }
can_destroy_planet_with_ACOT_HE_PLANET_KILLER_SHIELDER = { can_destroy_planet_with_PLANET_KILLER_SHIELDER = yes }
can_destroy_planet_with_ACOT_HE_PLANET_KILLER_NEUTRON = { can_destroy_planet_with_PLANET_KILLER_NEUTRON = yes }
can_destroy_planet_with_ACOT_HE_PLANET_KILLER_GODRAY = { can_destroy_planet_with_PLANET_KILLER_GODRAY = yes }
can_destroy_planet_with_ACOT_HE_PLANET_KILLER_NANOBOTS = { can_destroy_planet_with_PLANET_KILLER_NANOBOTS = yes }
can_destroy_planet_with_ACOT_EMISSARY_BEAM = {
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				text = acot_emissary_on_cooldown
				FROM = { NOT = { has_fleet_flag = acot_emissary_beam_delay } }
			}
			custom_tooltip = {
				fail_text = is_shielded
				NOR = {
					is_planet_class = pc_shielded
					is_planet_class = pc_ringworld_shielded
					is_planet_class = pc_habitat_shielded
				}
			}
			OR = {
				custom_tooltip = {
					text = acot_is_valid_for_emissary_beam
					OR = {
						NOT = { exists = space_owner }
						AND = {
							exists = space_owner
							space_owner = { is_same_value = from.owner }
						}
					}
					is_a_planet = yes
					is_asteroid = no
					is_star = no
					is_artificial = no
					merg_is_gas_giant = no
					merg_is_habitat = no
					merg_is_hab_ringworld = no
				}
			}
		"
		toggle = @has_ancient_caches
	}
}

############################### Ancient Empire ###############################
can_destroy_planet_with_ag_ancient_epsilon_planet_killer_weapon = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_untargetable = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = ag_requires_a_star_star_killer
				merg_is_empty_space = no
			}
			custom_tooltip = {
				fail_text = ag_requires_is_star_star_killer
				OR = {
					AND = {
						from.owner = {
							OR = {
								has_country_flag = ag_ship_subsystem_enabled_501_19
								OR = {
									has_country_flag = ag_epsilon_star_killer_planet_killer_mode
									has_country_flag = ag_epsilon_star_killer_planet_sweeper_mode
								}
								AND = {
									has_country_flag = ag_ship_subsystem_enabled_1001_19
									OR = {
										has_country_flag = ag_kappa_star_killer_planet_killer_mode
										has_country_flag = ag_kappa_star_killer_planet_sweeper_mode
									}
								}
							}
						}
						is_star = no
					}
					is_star = yes
				}
			}
			custom_tooltip = {
				fail_text = ag_requires_no_compact_star_star_killer
				merg_is_black_or_white_hole = no
			}
			custom_tooltip = {
				fail_text = ag_requires_outside_border_star_killer
				NOR = {
					AND = {
						from.owner = {
							NOR = {
								has_country_flag = ag_epsilon_star_killer_planet_killer_mode
								has_country_flag = ag_epsilon_star_killer_planet_sweeper_mode
							}
						}
						is_inside_border = from.owner
						solar_system = {
							any_system_planet = {
								OR = {
									is_colony = yes
									is_under_colonization = yes
								}
							}
						}
					}
					AND = {
						from.owner = {
							OR = {
								has_country_flag = ag_epsilon_star_killer_planet_killer_mode
								has_country_flag = ag_epsilon_star_killer_planet_sweeper_mode
							}
						}
						exists = owner
						owner = { is_same_value = from.owner }
					}
				}
			}
			custom_tooltip = {
				fail_text = ag_requires_declares_war_star_killer
				OR = {
					AND = {
						from.owner = {
							NOR = {
								has_country_flag = ag_epsilon_star_killer_planet_killer_mode
								has_country_flag = ag_epsilon_star_killer_planet_sweeper_mode
							}
						}
						OR = {
							is_inside_border = from.owner
							solar_system = { NOT = { exists = space_owner } }
							solar_system = {
								exists = space_owner
								space_owner = { is_hostile = from.owner }
							}
						}
					}
					AND = {
						from.owner = {
							OR = {
								has_country_flag = ag_epsilon_star_killer_planet_killer_mode
								has_country_flag = ag_epsilon_star_killer_planet_sweeper_mode
							}
						}
						NAND = {
							exists = owner
							owner = { NOT = { is_hostile = from.owner } }
						}
					}
				}
			}
			custom_tooltip = {
				fail_text = ag_requires_no_zeta_crisis_system
				NOT = { has_star_flag = ag_zeta_crisis_core_system }
			}
			custom_tooltip = {
				fail_text = ag_requires_no_special_system
				ag_is_star_killer_special_system = no
			}
			custom_tooltip = {
				fail_text = ag_requires_no_ancient_system
				ag_is_ancient_system = no
			}
			custom_tooltip = {
				fail_text = ag_requires_no_charging_star_killer
				from = {
					NOT = {
						any_controlled_ship = {
							is_ship_size = ag_epsilon_titan_1
							has_ship_flag = ag_epsilon_firing_star_killer_weapon
						}
					}
				}
			}
		"
		toggle = @ag_null_edict_length
	}
}
can_destroy_planet_with_ag_ancient_alpha_planet_killer_weapon = {
	optimize_memory
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		is_a_habitable_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	custom_tooltip = {
		fail_text = is_not_hostile
		OR = {
			merg_planet_is_hostile_or_crisis = yes
			AND = {
				exists = owner
				owner = { is_country_type = primitive }
				from.owner = { is_xenophobe = yes }
			}
			AND = {
				exists = space_owner
				exists = owner
				owner = { is_primitive = yes }
				space_owner = { merg_is_at_war = yes }
			}
		}
	}
	custom_tooltip = { fail_text = is_unpopulated OR = { num_pops > 0 is_planet_class = pc_infested } }
}
can_destroy_planet_with_ag_adv_divine_enforcer = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		is_a_habitable_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	custom_tooltip = {
		fail_text = fotd_cant_collossus
		NOT = { has_planet_flag = fotd_seperatist_planet@from.owner }
		exists = from.owner
		from.owner = { NOT = { has_country_flag = fotd_seperatist_country@from.owner } }
	}
	custom_tooltip = {
		fail_text = is_not_hostile_or_primitive
		OR = {
			planet_is_hostile = yes
			is_planet_class = pc_ai
			AND = { exists = owner owner = { is_country_type = primitive } }
			AND = { exists = owner owner = { is_same_value = from.owner } }
		}
	}
	if = {
		limit = { exists = owner owner = { is_country_type = primitive } }
		custom_tooltip = { fail_text = primitives_not_full_interference from.owner = { has_policy_flag = interference_aggressive } }
	}
	if = {
		limit = {
			NOR = { planet_is_hostile = yes AND = { exists = owner owner = { is_country_type = primitive } } }
			exists = owner
			owner = { is_same_value = from.owner }
		}
		custom_tooltip = { text = not_owned_test_fire exists = owner owner = { is_same_value = from.owner } }
	}
}

############################### APSR: Anomalies, Planetary and Space Resources ###############################
can_destroy_planet_with_PLANET_KILLER_APSR_DARK_ANGEL = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				text = apsr_dark_angel_only_for_standart_hostile_planets
				AND = {
					is_a_planet = yes
					OR = {
						AND = {
							exists = space_owner
							space_owner = { merg_is_at_war = yes }
						}
						AND = {
							exists = owner
							owner = { merg_is_at_war = yes }
						}
						AND = {
							exists = space_owner
							exists = owner
							owner = { is_primitive = yes }
							space_owner = { merg_is_at_war = yes }
						}
					}
				}
			}
			custom_tooltip = {
				fail_text = apsr_dark_angel_planet_lives_matter
				NOR = {
					merg_is_arcology = yes
					has_planet_flag = apsr_planet
				}
			}
			custom_tooltip = {
				fail_text = apsr_dark_angel_dark_planet
				is_apsr_dark = no
			}
		"
		toggle = @has_apsr
	}
}
can_destroy_planet_with_PLANET_KILLER_APSR_INATOR = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				text = apsr_inator_only_for_unhabitat_planet
				NOT = { exists = owner }
				OR = {
					NOT = { exists = space_owner }
					AND = {
						exists = space_owner
						space_owner = {
							OR = {
								is_same_value = from.owner
								AND = {
									is_subject = yes
									overlord = { is_same_value = from.owner  }
								}
							}
						}
					}
				}
				uninhabitable_regular_planet = yes
			}
			custom_tooltip = {
				fail_text = apsr_inator_planet_lives_matter
				NOR = {
					has_apsr_modifiers = yes
					has_modifier = terraforming_candidate
					has_modifier = frozen_terraforming_candidate
					has_modifier = toxic_terraforming_candidate
					has_modifier = apsr_terraforming_candidate
					has_modifier = apsr_restoration_candidate
					has_modifier = apsr_unshielded_candidate
					has_modifier = apsr_uninfected_candidate
				}
			}
		"
		toggle = @has_apsr
	}
}

############################### Archaeology Story Pack ###############################
can_destroy_planet_with_PLANET_KILLER_GEOCENTRIC_DEVICE = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		OR = {
			is_a_habitable_planet_megastructure = yes
			is_planet_class = pc_ai
		}
	}
	custom_tooltip = {
		fail_text = is_not_hostile_or_primitive
		OR = {
			merg_planet_is_hostile_or_crisis = yes
			AND = {
				exists = owner
				owner = { is_country_type = primitive }
			}
		}
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
}

############################### Arknights Near Future ###############################
can_destroy_planet_with_PLANET_KILLER_ARK_FROSTNOVA = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_standard_planet_or_megastructure
		is_star = no
		is_asteroid = no
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = ark_too_hot
				merg_is_molten = no
			}
			custom_tooltip = {
				fail_text = ark_gas_giant
				merg_is_gas_giant = no
				merg_is_gas_giant_habitable = no
			}
			custom_tooltip = {
				fail_text = ark_psionic
				NOR = {
					is_planet_class = pc_shrouded
				}
			}
			custom_tooltip = {
				fail_text = ark_shattered
				NOR = {
					is_planet_class = pc_shattered
					is_planet_class = pc_shattered_2
					is_planet_class = pc_broken
					is_planet_class = pc_machine_broken
				}
			}
		"
		toggle = @arknights_ANF
	}
	custom_tooltip = {
		fail_text = is_not_hostile_or_primitive
		OR = {
			AND = {
				exists = owner
				owner = { is_primitive = yes }
			}
			has_owner = no
			AND = {
				exists = space_owner
				space_owner = { merg_is_at_war = yes }
			}
		}
	}
}

############################### AshArms Aquarius History ###############################
can_destroy_planet_with_PLANET_KILLER_Ark_CRACKER = { can_destroy_planet_with_PLANET_KILLER_STAR_CRACKER = yes }
can_destroy_planet_with_PLANET_KILLER_JUMP_ADF = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_standard_planet_or_megastructure
		is_a_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	OR = {
		custom_tooltip = {
			text = is_not_hostile_cracker
			OR = {
				AND = {
					exists = space_owner
					space_owner = {
						OR = {
							merg_is_at_war = yes
							is_same_value = from.owner
						}
					}
				}
				AND = {
					# colony
					exists = owner
					owner = {
						OR = {
							merg_is_at_war = yes
							is_same_value = from.owner
						}
					}
				}
				AND = {
					# primitive
					exists = space_owner
					exists = owner
					owner = {
						is_primitive = yes
					}
					space_owner = {
						OR = {
							merg_is_at_war = yes
							is_same_value = from.owner
						}
					}
				}
			}
		}
	}
}

############################### AssaultLilly in Stellaris ###############################
can_destroy_planet_with_PLANET_KILLER_CRACKER_FAKE = { can_destroy_planet_with_PLANET_KILLER_CRACKER = yes }
can_destroy_planet_with_PLANET_KILLER_SHIELDER_FAKE = { can_destroy_planet_with_PLANET_KILLER_SHIELDER = yes }
can_destroy_planet_with_PLANET_KILLER_NEUTRON_FAKE = { can_destroy_planet_with_PLANET_KILLER_NEUTRON = yes }
can_destroy_planet_with_PLANET_KILLER_GODRAY_FAKE = { can_destroy_planet_with_PLANET_KILLER_GODRAY = yes }
can_destroy_planet_with_PLANET_KILLER_NANOBOTS_FAKE = { can_destroy_planet_with_PLANET_KILLER_NANOBOTS = yes }
planet_is_hostile_or_crisis_FAKE = { merg_planet_is_hostile_or_crisis = yes }
can_destroy_planet_with_PLANET_KILLER_PLANET_TO_NEST = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			NOT = { is_planet_class = pc_nest }
		"
		toggle = @change_planet_size_bullet_num
	}
	is_colony = yes
}

############################### Azur Lane Stellaris DLC ###############################
can_destroy_planet_with_azur_shippart_W2_T4 = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	is_star = yes
	merg_is_dense_star = no
	custom_tooltip = {
		text = is_not_hostile_cracker
		OR = {
			NOT = { exists = space_owner }
			AND = {
				exists = space_owner
				space_owner = {
					merg_is_at_war = yes
				}
			}
			AND = {
				exists = space_owner
				exists = owner
				owner = {
					is_primitive = yes
				}
				space_owner = {
					merg_is_at_war = yes
				}
			}
		}
	}
}
can_destroy_planet_with_milky_way_terminal_test_1 = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	is_star = yes
	merg_is_dense_star = no
	custom_tooltip = {
		text = is_not_hostile_cracker
		OR = {
			NOT = {
				exists = space_owner
			}
			AND = {
				exists = space_owner
				space_owner = {
					merg_is_at_war = yes
				}
			}
			AND = {
				exists = space_owner
				exists = owner
				owner = {
					is_primitive = yes
				}
				space_owner = {
					merg_is_at_war = yes
				}
			}
		}
	}
}
can_destroy_planet_with_milky_way_terminal_test_2 = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	is_star = yes
	merg_is_dense_star = no
	custom_tooltip = {
		text = is_not_hostile_cracker
		OR = {
			NOT = {
				exists = space_owner
			}
			AND = {
				exists = space_owner
				space_owner = {
					merg_is_at_war = yes
				}
			}
			AND = {
				exists = space_owner
				exists = owner
				owner = {
					is_primitive = yes
				}
				space_owner = {
					merg_is_at_war = yes
				}
			}
		}
	}
}
can_destroy_planet_with_azur_shippart_W3_T3 = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	is_star = yes
	custom_tooltip = {
		fail_text = need_a_planet_with_pops
		solar_system = {
			any_system_planet = {
				num_pops > 0
			}
		}
	}
	custom_tooltip = {
		text = is_not_hostile_cracker
		OR = {
			AND = {
				exists = space_owner
				space_owner = {
					merg_is_at_war = yes
				}
			}
			AND = {
				exists = space_owner
				exists = owner
				owner = {
					is_primitive = yes
				}
				space_owner = {
					merg_is_at_war = yes
				}
			}
		}
	}
}

############################### Destiny: Hive Portraits ###############################
can_destroy_planet_with_PLANET_KILLER_TAKEN_WEAPON = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = no_pops_to_compose
		OR = {
			num_pops > 0
			is_under_colonization = yes
			is_planet_class = pc_infested
			is_planet_class = pc_ai
		}
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		is_a_habitable_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	custom_tooltip = {
		fail_text = is_not_hostile_or_primitive
		OR = {
			planet_is_hostile = yes
			AND = {
				exists = owner
				owner = {
					is_country_type = primitive
				}
			}
		}
	}
	if = {
		limit = {
			exists = owner
			owner = { is_country_type = primitive }
		}
		custom_tooltip = {
			fail_text = primitives_not_in_borders
			exists = space_owner
			space_owner = { is_same_value = from.owner }
		}
	}
	custom_tooltip = {
		fail_text = no_assimilatable_pops
		any_owned_pop = {
			is_valid_pop_for_PLANET_KILLER_TAKEN_WEAPON = yes
		}
	}
}

############################### Destiny: Vex Portraits ###############################
can_destroy_planet_with_PLANET_KILLER_VEX_MACHINOFORMING_BEAM = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_habitable_non_artificial
		OR = {
			is_colonizable = yes
			is_colony = yes
		}
		is_artificial = no
	}
	custom_tooltip = {
		fail_text = fotd_cant_collossus
		NOT = { has_planet_flag = fotd_seperatist_planet@from.owner }
		exists = from.owner
		from.owner = {
			NOT = { has_country_flag = fotd_seperatist_country@from.owner }
		}
	}
	custom_tooltip = {
		fail_text = is_not_vex_machine_world
		NOT = { is_planet_class = pc_vex_machine } # is_vex_machine_world = no
	}
	if = {
		limit = { is_inside_border = from.owner }
		if = {
			limit = { #Uninhabited and primitive planets are always fine, if own colony then check if pops would be purged
				exists = owner
				owner = { is_same_value = from.owner }
				any_owned_species = {
					is_valid_pop_for_PLANET_KILLER_VEX_MACHINOFORMING_BEAM = yes
				}
			}
			custom_tooltip = {
				fail_text = requires_purge_allowed
				success_text = will_convert_non_vex_pops
				from.owner = {
					is_ai = no
					has_policy_flag = purge_allowed
				}
			}
		}
	}
	else = {
		custom_tooltip = {
			fail_text = is_not_hostile_or_primitive_or_ours
			OR = {
				planet_is_hostile_or_crisis = yes
				AND = {
					exists = owner
					owner = {
						is_country_type = primitive
					}
				}
			}
		}
	}
	if = {
		limit = {
			exists = owner
			owner = { is_country_type = primitive }
		}
		custom_tooltip = {
			fail_text = primitives_not_in_borders
			exists = space_owner
			space_owner = { is_same_value = from.owner }
		}
		custom_tooltip = {
			fail_text = primitives_not_full_interference
			from.owner = {
				has_policy_flag = interference_aggressive
			}
		}
	}
}

############################### EDA ###############################
can_destroy_planet_with_PLANET_KILLER_EDA_STAR_CRACKER = { can_destroy_planet_with_PLANET_KILLER_STAR_CRACKER = yes }

############################### Electroids ###############################
can_destroy_planet_with_PLANET_KILLER_ELEC_FOCUS = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = elec_must_be_colony
		is_colony = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	custom_tooltip = {
		fail_text = is_not_hostile
		OR = {
			custom_tooltip = {
				text = is_not_hostile_cracker
				OR = {
					AND = { # colony
						exists = owner
						owner = {
							merg_is_at_war = yes
						}
					}
					AND = { # primitive
						exists = space_owner
						exists = owner
						owner = {
							is_primitive = yes
						}
						space_owner = {
							merg_is_at_war = yes
						}
					}
				}
			}
		}
	}
}

############################### Empires Expanded ###############################
can_destroy_planet_with_PLANET_KILLER_CORRUPT = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_standard_planet_or_megastructure
		is_a_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = is_already_corrupt
				is_corrupted_world_emex = no
			}
		"
		toggle = @has_emex_mod
	}
	OR = {
		custom_tooltip = {
			text = is_not_hostile_cracker
			inline_script = {
				script = merger_of_rules/toggled_code
				code = "
					OR = {
				AND = {
					exists = space_owner
					space_owner = {
						OR = {
							merg_is_at_war = yes
							is_country_type = master_ai_country
						}
					}
				}
				AND = {
					# colony
					exists = owner
					owner = {
						OR = {
							merg_is_at_war = yes
							is_country_type = primitive
							is_country_type = master_ai_country
						}
					}
				}
				AND = {
					# primitive
					exists = space_owner
					exists = owner
					owner = {
						is_primitive = yes
					}
					space_owner = {
						OR = {
							merg_is_at_war = yes
							is_country_type = master_ai_country
						}
					}
				}
			}
				"
				toggle = @has_emex_mod
			}
		}
		custom_tooltip = {
			fail_text = is_not_hostile
			OR = {
				merg_planet_is_hostile_or_crisis = yes
				AND = {
					exists = owner
					owner = { is_country_type = primitive }
					from.owner = { is_xenophobe = yes }
				}
				AND = { # at war with primitive space owner
					exists = space_owner
					exists = owner
					owner = { is_primitive = yes }
					space_owner = {
						merg_is_at_war = yes
					}
				}
			}
		}
	}
}

############################### Empire of eeveelution ###############################
can_destroy_planet_with_PLANET_KILLER_EOE = { can_destroy_planet_with_PLANET_KILLER_CRACKER = yes }
can_destroy_planet_with_PLANET_KILLER_FIRE_EOE = { can_destroy_planet_with_PLANET_KILLER_CRACKER = yes }
can_destroy_planet_with_PLANET_KILLER_FIRE_EOE_SMALL = { can_destroy_planet_with_PLANET_KILLER_CRACKER = yes }
can_destroy_planet_with_PLANET_KILLER_OKRA = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		is_a_habitable_planet_megastructure = yes
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = EOE_is_not_our_planet
				AND = {
					exists = space_owner
					space_owner = { is_same_value = from.owner }
				}
			}
			custom_tooltip = {
				fail_text = EOE_already_have_modifier
				NOT = {
					has_modifier = EOE_OKRA_effect
				}
			}
		"
		toggle = @s7_EOE_cost
	}
}
can_destroy_planet_with_PLANET_KILLER_NECROZMA= {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_your_megastructure_system
		NOT = {
			solar_system = {
				has_star_flag = crisis_sphere_system@from.owner
				any_system_megastructure = { has_megastructure_flag = crisis_sphere }
			}
		}
	}
	custom_tooltip = {
		fail_text = is_not_star
		is_star = yes
	}
	custom_tooltip = {
		fail_text = is_black_hole
		NOT = { is_planet_class = pc_black_hole }
	}
	custom_tooltip = {
		fail_text = star_owner_is_not_hostile
		OR = {
			NOT = { exists = space_owner }
			space_owner = { is_hostile = from.owner }
			space_owner = { is_same_value = from.owner }
		}
	}
}

# Genshin Impact
can_destroy_planet_with_PLANET_KILLER_TIWATE_SHIPPART_XINGQIUTAIHAI = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		is_a_habitable_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	custom_tooltip = {
		fail_text = is_not_hostile_or_primitive
		OR = {
			planet_is_hostile_or_crisis = yes
			AND = {
				exists = owner
				owner = { is_country_type = primitive }
			}
		}
	}
	if = {
		limit = {
			exists = owner
			owner = { is_country_type = primitive }
		}
		custom_tooltip = {
			fail_text = primitives_not_in_borders
			exists = space_owner
			space_owner = { is_same_value = from.owner }
		}
	}
}

############################### Gigastructural Engineering & More ###############################
can_destroy_planet_with_PLANET_KILLER_BLOKKAT_GENERATOR = {
	is_colony = no
	is_star = no
	OR = {
		uninhabitable_regular_planet = yes
		is_asteroid = yes
	}
}
can_destroy_planet_with_PLANET_KILLER_BLOKKAT_HARVESTER = {
	custom_tooltip = {
		fail_text = needs_regular_star_blokkat_harvest
		is_star = yes
		solar_system = {
			inline_script = {
				script = merger_of_rules/toggled_code
				code = "
					systems_blokkats_wont_stripmine = no
				"
				toggle = @has_gigastructures
			}
			merg_is_void_system = no
		}
	}
}

############################### Girls Frontline ###############################
can_destroy_planet_with_PLANET_KILLER_GF_COLLAPSE_ENDING_FLASH = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_standard_planet_or_megastructure
		is_a_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	OR = {
		custom_tooltip = {
			text = is_not_hostile_cracker
			OR = {
				AND = {
					exists = space_owner
					space_owner = {
						merg_is_at_war = yes
					}
				}
				AND = {
					exists = owner
					owner = {
						merg_is_at_war = yes
					}
				}
				AND = {
					exists = space_owner
					exists = owner
					owner = { is_primitive = yes }
					space_owner = {
						merg_is_at_war = yes
					}
				}
			}
		}
		custom_tooltip = {
			text = not_barren_molten_frozen_toxic_test_fire
			NOT = { exists = owner }
			OR = {
				NOT = { exists = space_owner }
				AND = {
					exists = space_owner
					space_owner = { is_same_value = from.owner }
				}
			}
			merg_is_valid_for_test_fire = yes
		}
	}
}

############################### Halo: Forerunner Ships & Portraits ###############################
can_destroy_planet_with_PLANET_KILLER_COMPOSER = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = no_pops_to_compose
		OR = {
			num_pops > 0
			is_under_colonization = yes
			is_planet_class = pc_infested
			is_planet_class = pc_ai
		}
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		is_a_habitable_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	custom_tooltip = {
		fail_text = is_not_hostile_or_primitive
		OR = {
			planet_is_hostile = yes
			AND = {
				exists = owner
				owner = {
					is_country_type = primitive
				}
			}
		}
	}
	if = {
		limit = {
			exists = owner
			owner = { is_country_type = primitive }
		}
		custom_tooltip = {
			fail_text = primitives_not_in_borders
			exists = space_owner
			space_owner = { is_same_value = from.owner }
		}
		custom_tooltip = {
			fail_text = primitives_not_full_interference
			from.owner = {
				has_policy_flag = interference_aggressive
			}
		}
	}
	custom_tooltip = {
		fail_text = no_assimilatable_pops
		any_owned_pop = {
			is_valid_pop_for_PLANET_KILLER_COMPOSER = yes
		}
	}
}
can_destroy_planet_with_PLANET_KILLER_FORERUNNER_ATTENUATION_WEAPON = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		OR = {
			is_a_habitable_planet_megastructure = yes
			is_planet_class = pc_ai
			merg_is_shielded = no
		}
	}
	if = {
		limit = {
			exists = owner
			owner = { is_country_type = primitive }
		}
		custom_tooltip = {
			fail_text = primitives_not_full_interference
			from.owner = {
				has_policy_flag = interference_aggressive
			}
		}
	}
}

############################### Hypertraversal Manipulation ###############################
can_destroy_planet_with_hyperspace_augur_beam = {
	is_star = yes
	merg_is_empty_space = no
	NOR = {
		has_star_flag = sealed_system
		has_star_flag = lcluster
		# Ancient Empire
		has_star_flag = ag_no_jump_in_system
		# ACOT
		has_star_flag = outercluster
		# Warship Girls R And MIST Species
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				has_star_flag = wg_sealed_system
				has_star_flag = wg_psionic_systems
			"
			toggle = @wsg_mod
		}
		# Gigastructural Engineering & More
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				has_star_flag = ndb_immune_system
				cohesive_system = yes
				urmazin_system = yes
				everchanging_system = yes
				katzen_jump_blocked_system = yes
				has_star_flag = maginot_anti_jump_star
				has_star_flag = siegfried_anti_jump_star
				giga_is_core_system = yes
			"
			toggle = @has_gigastructures
		}
		# Some Events of Outside Cluster
		has_star_flag = nep_Krahen_cluster
		has_star_flag = nep_Scrus_cluster
	}
}

############################### KDC Story Pack ###############################
can_destroy_planet_with_PLANET_KILLER_GRAYGOO = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_standard_planet_or_megastructure
		is_a_planet_megastructure = yes
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = is_not_pc_graygoo
				NOT = { is_planet_class = pc_gray_goo }
			}
		"
		toggle = @gray_t1_tech_days
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	OR = {
		custom_tooltip = {
			text = is_not_hostile_cracker
			OR = {
				AND = {
					exists = space_owner
					space_owner = { merg_planet_is_hostile_or_crisis = yes }
				}
				AND = { # colony
					exists = owner
					owner = { merg_planet_is_hostile_or_crisis = yes }
				}
				AND = { # primitive
					exists = space_owner
					exists = owner
					owner = {
						is_primitive = yes
					}
					space_owner = { merg_planet_is_hostile_or_crisis = yes }
				}
			}
		}
		custom_tooltip = {
			text = not_barren_molten_frozen_toxic_test_fire
			NOT = { exists = owner }
			OR = {
				NOT = { exists = space_owner }
				AND = {
					exists = space_owner
					space_owner = { is_same_value = from.owner }
				}
			}
			merg_is_valid_for_test_fire = yes
		}
	}
}

############################### Krogan's Sci Fi Stuff Pack ###############################
can_destroy_planet_with_DEATH_STAR_WEAPON = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_standard_planet_or_megastructure
		is_a_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
}

############################### Nanite Expansion Continued ###############################
can_destroy_planet_with_PLANET_KILLER_NANO = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_standard_planet_or_megastructure
		is_a_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	OR = {
		custom_tooltip = {
			text = is_not_hostile_cracker
			OR = {
				AND = {
					exists = space_owner
					space_owner = {
						merg_is_at_war = yes
					}
				}
				AND = {
					# colony
					exists = owner
					owner = {
						merg_is_at_war = yes
					}
				}
				AND = {
					exists = space_owner
					exists = owner
					owner = {
						is_primitive = yes
					}
					space_owner = {
						merg_is_at_war = yes
					}
				}
			}
		}
		OR = {
			custom_tooltip = {
				text = not_barren_molten_frozen_toxic_test_fire
				NOT = { exists = owner }
				OR = {
					NOT = { exists = space_owner }
					AND = {
						exists = space_owner
						space_owner = { is_same_value = from.owner }
					}
				}
				merg_is_valid_for_test_fire = yes
			}
		}
	}
}
# kills only the pops and keeps the planet intact, so Gigastructure planets are a valid target
can_destroy_planet_with_PLANET_KILLER_HARBINGER = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_standard_planet_or_megastructure
		is_a_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_not_hostile
		OR = {
			custom_tooltip = {
				text = is_not_hostile_cracker
				OR = {
					AND = {
						exists = space_owner
						space_owner = {
							merg_is_at_war = yes
						}
					}
					AND = {
						# colony
						exists = owner
						owner = {
							merg_is_at_war = yes
						}
					}
					AND = {
						# primitive
						exists = space_owner
						exists = owner
						owner = {
							is_primitive = yes
						}
						space_owner = {
							merg_is_at_war = yes
						}
					}
				}
			}
			custom_tooltip = {
				text = not_barren_molten_frozen_toxic_test_fire
				NOT = { exists = owner }
				OR = {
					NOT = { exists = space_owner }
					AND = {
						exists = space_owner
						space_owner = { is_same_value = from.owner }
					}
				}
				is_colony = yes
			}
		}
	}
	custom_tooltip = {
		fail_text = is_shielded
		NOR = {
			is_ds_kompass = yes
			merg_is_shielded = yes
		}
	}
}

############################### Nanite Machines & Distant Stars Overhaul ###############################
can_destroy_planet_with_PLANET_KILLER_HARVESTER = { can_destroy_planet_with_PLANET_KILLER_CRACKER = yes }

############################### Null Void Colossus ###############################
can_destroy_planet_with_PLANET_KILLER_NULLVOID = { can_destroy_planet_with_PLANET_KILLER_CRACKER = yes }

############################### Nyto Species Pack ###############################
can_destroy_planet_with_tech_GFnyto_accelerating_coil3 = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_standard_planet_or_megastructure
		is_a_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
}

############################### Origin Beings ###############################
can_destroy_planet_with_PLANET_KILLER_STAR_CRACKER_SERES = { can_destroy_planet_with_PLANET_KILLER_STAR_CRACKER = yes }

############################### Planetary Diversity ###############################
can_destroy_planet_with_PLANET_KILLER_PD_NECRO_RAY = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_habitable_non_artificial
		OR = {
			is_colonizable = yes
			is_colony = yes
		}
		is_artificial = no
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = is_not_necro
				pd_aw_is_necro_planet = no
			}
		"
		toggle = @has_planetary_diversity_ascension_worlds
	}
	if = {
		limit = { is_inside_border = from.owner }
		if = {
			limit = { #Uninhabited and primitive planets are always fine, if own colony then check if pops would be purged
				exists = owner
				owner = { is_same_value = from.owner }
			}
			custom_tooltip = {
				fail_text = requires_purge_allowed
				success_text = will_purge_robots_and_zombie
				from.owner = {
					is_ai = no
					has_policy_flag = purge_allowed
				}
			}
		}
	}
	else = {
		custom_tooltip = {
			fail_text = is_not_hostile_or_primitive_or_ours
			OR = {
				merg_planet_is_hostile_or_crisis = yes
				AND = {
					exists = owner
					owner = { is_country_type = primitive }
				}
			}
		}
	}
	if = {
		limit = {
			exists = owner
			owner = { is_country_type = primitive }
		}
		custom_tooltip = {
			fail_text = primitives_not_in_borders
			exists = space_owner
			space_owner = { is_same_value = from.owner }
		}
		custom_tooltip = {
			fail_text = primitives_not_full_interference
			from.owner = {
				has_policy_flag = interference_aggressive
			}
		}
	}
}

############################### Protoss ###############################
can_destroy_planet_with_archon_power_pouring = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_standard_planet_or_megastructure
		is_asteroid = no
		NOR = {
			is_planet_class = pc_shattered
			is_planet_class = pc_shattered_2
		}
	}
	OR = {
		NOT = { solar_system = { exists = owner } }
		AND = {
			solar_system = {
				exists = owner
				owner = { is_hostile = from.owner }
			}
		}
	}
}
can_destroy_planet_with_RG_PLANET_KILLER = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_untargetable = no
	}
	custom_tooltip = {
		fail_text = "RG_requires_a_star_star_killer"
		merg_is_empty_space = no
	}
	custom_tooltip = {
		fail_text = "RG_requires_outside_border_star_killer"
		NOR = {
			AND = {
				is_inside_border = from.owner
				solar_system = {
					any_system_planet = {
						OR = {
							is_colony = yes
							is_under_colonization = yes
						}
					}
				}
			}
			AND = {
				exists = owner
				owner = {
					is_same_value = from.owner
				}
			}
		}
	}
	custom_tooltip = {
		fail_text = "RG_requires_no_pacifist_star_killer"
		from.owner = {
			NOR = {
				has_ethic = ethic_fanatic_pacifist
				has_ethic = ethic_pacifist
			}
		}
	}
}
can_destroy_planet_with_RG_PLANET_KILLER_SMALL = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_untargetable = no
	}
	custom_tooltip = {
		fail_text = "RG_requires_a_star_star_killer"
		NOR = {
			is_star = yes
			merg_is_empty_space = yes
		}
	}
	custom_tooltip = {
		fail_text = "RG_requires_outside_border_star_killer"
		NOR = {
			AND = {
				is_inside_border = from.owner
				solar_system = {
					any_system_planet = {
						OR = {
							is_colony = yes
							is_under_colonization = yes
						}
					}
				}
			}
			AND = {
				exists = owner
				owner = {
					is_same_value = from.owner
				}
			}
		}
	}
	custom_tooltip = {
		fail_text = "RG_requires_no_pacifist_star_killer"
		from.owner = {
			NOR = {
				has_ethic = ethic_fanatic_pacifist
				has_ethic = ethic_pacifist
			}
		}
	}
}
can_destroy_planet_with_RG_PLANET_KILLER_SP = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_untargetable = no
	}
	custom_tooltip = {
		fail_text = "RG_requires_a_star_star_killer"
		NOR = {
			is_star = yes
			merg_is_empty_space = yes
		}
	}
	custom_tooltip = {
		fail_text = "RG_requires_inside_border_star_killer"
		is_inside_border = from.owner
	}
}
can_destroy_planet_with_RG_PLANET_KILLER_SHIELDER = { can_destroy_planet_with_PLANET_KILLER_SHIELDER = yes }
can_destroy_planet_with_RG_PLANET_KILLER_NEUTRON = { can_destroy_planet_with_PLANET_KILLER_NEUTRON = yes }
can_destroy_planet_with_RG_PLANET_KILLER_GODRAY = { can_destroy_planet_with_PLANET_KILLER_GODRAY = yes }
can_destroy_planet_with_RG_PLANET_KILLER_NANOBOTS = { can_destroy_planet_with_PLANET_KILLER_NANOBOTS = yes }
can_destroy_planet_with_RG_PLANET_KILLER_DELUGE = { can_destroy_planet_with_PLANET_KILLER_DELUGE = yes }
can_destroy_planet_with_RG_PLANET_KILLER_STAR_CRACKER = { can_destroy_planet_with_PLANET_KILLER_STAR_CRACKER = yes }

############################### Return of Ragnarok ###############################
can_destroy_planet_with_N_ISBS_RAGNAROK_SPEAR_OF_LONGINUS = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	if = {
		limit = {
			exists = owner
			owner = { is_country_type = primitive }
		}
		custom_tooltip = {
			fail_text = primitives_not_full_interference
			from.owner = {
				has_policy_flag = interference_aggressive
			}
		}
	}
	custom_tooltip = {
		fail_text = N_ISBS_longinus_triggers
		OR = {
			owner = { is_hostile = from.owner }
			space_owner = { is_hostile = from.owner }
			NOT = { exists = space_owner }
			AND = {
				exists = space_owner
				space_owner = { is_same_value = from.owner }
			}
		}
	}
	custom_tooltip = {
		fail_text = N_ISBS_longinus_hited
		NOT = { has_modifier = N_ISBS_longinus_hit_planet_modifier }
	}
}

############################### Rozen Maiden Suigintou Leader Pack ###############################
can_destroy_planet_with_GE_PLANET_KILLER_Crasher = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	is_star = yes
}
can_destroy_planet_with_GE_PLANET_KILLER_CRACKER = { can_destroy_planet_with_PLANET_KILLER_CRACKER = yes }
can_destroy_planet_with_GE_PLANET_KILLER_SHIELDER = { can_destroy_planet_with_PLANET_KILLER_SHIELDER = yes }
can_destroy_planet_with_GE_PLANET_KILLER_NEUTRON = { can_destroy_planet_with_PLANET_KILLER_NEUTRON = yes }
can_destroy_planet_with_GE_PLANET_KILLER_GODRAY = { can_destroy_planet_with_PLANET_KILLER_GODRAY = yes }
can_destroy_planet_with_GE_PLANET_KILLER_NANOBOTS = { can_destroy_planet_with_PLANET_KILLER_NANOBOTS = yes }
can_destroy_planet_with_GE_PLANET_KILLER_DELUGE = { can_destroy_planet_with_PLANET_KILLER_DELUGE = yes }

############################### Sensible Late Game Techs ###############################
can_destroy_planet_with_slgt_planet_killer_knid = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		OR = {
			is_a_habitable_planet_megastructure = yes
			is_planet_class = pc_ai
		}
	}
	custom_tooltip = {
		fail_text = is_not_hostile_or_primitive
		OR = {
			merg_planet_is_hostile_or_crisis = yes
			AND = {
				exists = owner
				owner = { is_country_type = primitive }
			}
		}
	}
	if = {
		limit = {
			exists = owner
			owner = { is_country_type = primitive }
		}
		custom_tooltip = {
			fail_text = primitives_not_full_interference
			from.owner = {
				has_policy_flag = interference_aggressive
			}
		}
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
}

############################### Shroud Expanded - The Decadence of Sanity ###############################
can_destroy_planet_with_PLANET_KILLER_SHROUD = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_standard_planet_or_megastructure
		is_a_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	OR = {
		custom_tooltip = {
			text = is_not_hostile_cracker
			OR = {
				AND = {
					exists = space_owner
					space_owner = { merg_is_at_war = yes }
				}
				AND = { # colony
					exists = owner
					owner = { merg_is_at_war = yes }
				}
				AND = { # crisis
					exists = space_owner
					space_owner = { merg_is_at_war = yes }
				}
			}
		}
		custom_tooltip = {
			text = is_not_a_standard_planet_or_megastructure
			OR = {
				NOT = { exists = space_owner }
				AND = {
					exists = space_owner
					space_owner = { is_same_value = from.owner }
				}
			}
			OR = {
				merg_is_hab_ringworld = yes
				merg_is_habitat = yes
			}
		}
	}
}

############################### Some Events of Outside Cluster ###############################
can_destroy_planet_with_PLANET_KILLER_NEP_UGO = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		is_a_habitable_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = nep_no_sapient_pops
				any_owned_pop = { is_sapient = yes }
			}
		"
		toggle = @has_seooc_mod
	}
}

############################### StellarisCraft ###############################
can_destroy_planet_with_daelaam_giant_twilight_archon_power_overwhelming = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_standard_planet_or_megastructure
		is_a_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	custom_tooltip = {
		fail_text = fotd_cant_collossus
		NOT = { has_planet_flag = fotd_seperatist_planet@from.owner }
		exists = from.owner
		from.owner = {
			NOT = { has_country_flag = fotd_seperatist_country@from.owner }
		}
	}
	OR = {
		custom_tooltip = {
			text = is_not_hostile_cracker
			OR = {
				AND = {
					exists = space_owner
					space_owner = {
						merg_is_at_war = yes
					}
				}
				AND = { # colony
					exists = owner
					owner = {
						merg_is_at_war = yes
					}
				}
			}
		}
		AND = {
			# primitive target
			custom_tooltip = {
				text = cannot_crack_pre_ftl_planet_ownership
				exists = space_owner
				exists = owner
				owner = {
					is_primitive = yes
				}
				space_owner = {
					merg_is_at_war = yes
				}
			}
			custom_tooltip = {
				text = cannot_crack_pre_ftl_planet_interference
				# primitive
				exists = owner
				owner = {
					is_primitive = yes
				}
				from.owner = {
					has_policy_flag = interference_aggressive
				}
			}
		}
		custom_tooltip = {
			text = not_barren_molten_frozen_toxic_test_fire
			NOT = { exists = owner }
			OR = {
				NOT = { exists = space_owner }
				AND = {
					exists = space_owner
					space_owner = { is_same_value = from.owner }
				}
			}
			merg_is_valid_for_test_fire = yes
		}
	}
}

############################### StellarRegulator Array ###############################
can_destroy_planet_with_SRA_T4_weapon_planet_killer = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = SRA_requires_a_star_star_killer
				merg_is_empty_space = no
			}
		"
		toggle = @SRA_t_weapon_shield_damage
	}
	custom_tooltip = {
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				fail_text = SRA_requires_is_star_star_killer
			"
			toggle = @SRA_t_weapon_shield_damage
		}
		OR = {
			AND = {
				from.owner = {
					OR = {
						has_country_flag = SRA_T4_weapon_planet_killer_killer_mode
						has_country_flag = SRA_T4_weapon_planet_killer_sweeper_mode
					}
				}
				is_star = no
			}
			is_star = yes
		}
	}
	custom_tooltip = {
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				fail_text = SRA_requires_outside_border_star_killer
			"
			toggle = @SRA_t_weapon_shield_damage
		}
		NOR = {
			AND = {
				from.owner = {
					NOR = {
						has_country_flag = SRA_T4_weapon_planet_killer_killer_mode
						has_country_flag = SRA_T4_weapon_planet_killer_sweeper_mode
					}
				}
				is_inside_border = from.owner
				solar_system = {
					any_system_planet = {
						OR = {
							is_colony = yes
							is_under_colonization = yes
						}
					}
				}
			}
			AND = {
				from.owner = {
					OR = {
						has_country_flag = SRA_T4_weapon_planet_killer_killer_mode
						has_country_flag = SRA_T4_weapon_planet_killer_sweeper_mode
					}
				}
				exists = owner
				owner = { is_same_value = from.owner }
			}
		}
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = SRA_requires_declares_war_star_killer
				NAND = {
					has_country_flag = SRA_T4_weapon_planet_killer_killer_mode
					has_country_flag = SRA_T4_weapon_planet_killer_sweeper_mode
				}
			}
			custom_tooltip = {
				fail_text = SRA_requires_no_ancient_system
				SRA_is_ancient_system = no
			}
			custom_tooltip = {
				fail_text = SRA_requires_no_zeta_crisis_system
				NOT = { has_star_flag = ag_zeta_crisis_core_system }
			}
			custom_tooltip = {
				fail_text = SRA_requires_no_special_system
				SRA_is_special_system = no
			}
		"
		toggle = @SRA_t_weapon_shield_damage
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = SRA_requires_no_is_cloaked
				from = { is_cloaked = no }
			}
		"
		toggle = @SRA_t_weapon_shield_damage
	}
}
can_destroy_planet_with_SRA_Rokia_dragon_weapon_planet_killer = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		is_a_habitable_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	custom_tooltip = {
		fail_text = is_not_hostile_or_primitive
		OR = {
			planet_is_hostile = yes
			AND = {
				exists = owner
				owner = {
					is_country_type = primitive
				}
			}
		}
	}
	if = {
		limit = {
			exists = owner
			owner = { is_country_type = primitive }
		}
		custom_tooltip = {
			fail_text = primitives_not_in_borders
			exists = space_owner
			space_owner = { is_same_value = from.owner }
		}
		custom_tooltip = {
			fail_text = primitives_not_full_interference
			from.owner = {
				has_policy_flag = interference_aggressive
			}
		}
	}
}

############################### ThaumStellaris ###############################
can_destroy_planet_with_TC_PLANET_KILLER_EXCAVATION = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = tc_planet_killer_not_target
				NOR = {
					merg_is_shielded = yes
					is_asteroid = yes
					is_tc_invisible = yes
				}

				NOT = { has_planet_flag = tc_not_pk_target }
				is_star = no
			}
			custom_tooltip = {
				fail_text = tc_planet_killer_excavation_nothing_dig
				NOT = {
					is_tc_bedrock = yes
				}
			}
			custom_tooltip = {
				fail_text = tc_planet_killer_not_hostile
				OR = {
					AND = {
						custom_tooltip = {
							fail_text = tc_planet_killer_excavation_our_planet
							NOT = { exists = owner }
							exists = space_owner
							space_owner = { is_same_value = from.owner }
						}
					}
					AND = {
						custom_tooltip = {
							text = is_not_hostile_cracker
							OR = {
								AND = {
									exists = space_owner
									space_owner = {
										merg_is_at_war = yes
									}
								}
								AND = { # colony
									exists = owner
									owner = {
										merg_is_at_war = yes
									}
								}
								AND = { # primitive
									exists = space_owner
									exists = owner
									owner = {
										is_primitive = yes
									}
									space_owner = {
										merg_is_at_war = yes
									}
								}
							}
						}
					}
				}
			}
		"
		toggle = @has_tc_mod
	}
}
can_destroy_planet_with_TC_PLANET_KILLER_EXCAVATION_TURRET = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = tc_planet_killer_not_target
				NOR = {
					merg_is_shielded = yes
					is_asteroid = yes
					is_tc_invisible = yes
				}

				NOT = { has_planet_flag = tc_not_pk_target }
				is_star = no
			}
			custom_tooltip = {
				fail_text = tc_planet_killer_excavation_nothing_dig
				NOT = {
					is_tc_bedrock = yes
				}
			}
			custom_tooltip = {
				fail_text = tc_planet_killer_not_hostile
				OR = {
					AND = {
						custom_tooltip = {
							fail_text = tc_planet_killer_excavation_our_planet
							NOT = { exists = owner }
							exists = space_owner
							space_owner = { is_same_value = from.owner }
						}
					}
					AND = {
						custom_tooltip = {
							text = is_not_hostile_cracker
							OR = {
								AND = {
									exists = space_owner
									space_owner = {
										merg_is_at_war = yes
									}
								}
								AND = { # colony
									exists = owner
									owner = {
										merg_is_at_war = yes
									}
								}
								AND = { # primitive
									exists = space_owner
									exists = owner
									owner = {
										is_primitive = yes
									}
									space_owner = {
										merg_is_at_war = yes
									}
								}
							}
						}
					}
				}
			}
		"
		toggle = @has_tc_mod
	}
}
can_destroy_planet_with_TC_PLANET_KILLER_TAINTED_STORM = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = tc_planet_killer_not_target

				NOT = { has_planet_flag = tc_not_pk_target }
			}
		"
		toggle = @has_tc_mod
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		OR = {
			is_a_habitable_planet_megastructure = yes
			is_planet_class = pc_ai
		}
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	custom_tooltip = {
		fail_text = is_not_hostile_or_primitive
		OR = {
			planet_is_hostile_or_crisis = yes
			AND = {
				exists = owner
				owner = {
					is_country_type = primitive
				}
			}
		}
	}
}
can_destroy_planet_with_TC_PLANET_KILLER_TAINTED_STORM_TURRET = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = tc_planet_killer_not_target

				NOT = { has_planet_flag = tc_not_pk_target }
			}
		"
		toggle = @has_tc_mod
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		OR = {
			is_a_habitable_planet_megastructure = yes
			is_planet_class = pc_ai
		}
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	custom_tooltip = {
		fail_text = is_not_hostile_or_primitive
		OR = {
			planet_is_hostile_or_crisis = yes
			AND = {
				exists = owner
				owner = {
					is_country_type = primitive
				}
			}
		}
	}
}
can_destroy_planet_with_TC_PLANET_KILLER_FROST = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = tc_planet_killer_not_target
				NOR = {
					merg_is_shielded = yes
					is_asteroid = yes
					is_tc_invisible = yes
					is_tc_bedrock = yes
					is_planet_class = pc_ringworld_habitable_damaged
				}

				NOT = { has_planet_flag = tc_not_pk_target }
				is_star = no
			}
			custom_tooltip = {
				fail_text = tc_planet_killer_frost_frozen_target
				merg_is_frozen = no
			}
			custom_tooltip = {
				fail_text = tc_planet_killer_not_hostile
				OR = {
					AND = {
						custom_tooltip = {
							fail_text = tc_planet_killer_frost_our_planet
							NOT = { exists = owner }
							exists = space_owner
							space_owner = { is_same_value = from.owner }
							is_artificial = no
						}
					}
					AND = {
						custom_tooltip = {
							fail_text = is_not_hostile_or_primitive
							OR = {
								AND = {
									exists = space_owner
									space_owner = {
										merg_is_at_war = yes
									}
									is_artificial = no
								}
								AND = { # colony
									exists = owner
									owner = {
										merg_is_at_war = yes
									}
								}
								AND = { # primitive
									exists = space_owner
									exists = owner
									owner = {
										is_primitive = yes
									}
									space_owner = {
										merg_is_at_war = yes
									}
								}
							}
						}
					}
				}
			}
		"
		toggle = @has_tc_mod
	}
}
can_destroy_planet_with_TC_PLANET_KILLER_FROST_TURRET = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = tc_planet_killer_not_target
				NOR = {
					merg_is_shielded = yes
					is_asteroid = yes
					is_tc_invisible = yes
					is_tc_bedrock = yes
					is_planet_class = pc_ringworld_habitable_damaged
				}

				NOT = { has_planet_flag = tc_not_pk_target }
				is_star = no
			}
			custom_tooltip = {
				fail_text = tc_planet_killer_frost_frozen_target
				merg_is_frozen = no
			}
			custom_tooltip = {
				fail_text = tc_planet_killer_not_hostile
				OR = {
					AND = {
						custom_tooltip = {
							fail_text = tc_planet_killer_frost_our_planet
							NOT = { exists = owner }
							exists = space_owner
							space_owner = { is_same_value = from.owner }
							is_artificial = no
						}
					}
					AND = {
						custom_tooltip = {
							fail_text = is_not_hostile_or_primitive
							OR = {
								AND = {
									exists = space_owner
									merg_is_at_war = yes
									is_artificial = no
								}
								AND = { # colony
									exists = owner
									owner = {
										merg_is_at_war = yes
									}
								}
								AND = { # primitive
									exists = space_owner
									exists = owner
									owner = {
										is_primitive = yes
									}
									space_owner = {
										merg_is_at_war = yes
									}
								}
							}
						}
					}
				}
			}
		"
		toggle = @has_tc_mod
	}
}
can_destroy_planet_with_TC_PLANET_KILLER_LIQUEFACTION = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = tc_planet_killer_not_target
				NOR = {
					merg_is_shielded = yes
					is_asteroid = yes
					is_tc_invisible = yes
					is_tc_bedrock = yes
					is_planet_class = pc_ringworld_habitable_damaged
				}

				NOT = { has_planet_flag = tc_not_pk_target }
				is_star = no
			}
			custom_tooltip = {
				fail_text = tc_planet_killer_liquefaction_molten_target
				merg_is_molten = yes
			}
			custom_tooltip = {
				fail_text = tc_planet_killer_not_hostile
				OR = {
					AND = {
						custom_tooltip = {
							fail_text = tc_planet_killer_liquefaction_our_planet
							NOT = { exists = owner }
							exists = space_owner
							space_owner = { is_same_value = from.owner }
							is_artificial = no
						}
					}
					AND = {
						custom_tooltip = {
							fail_text = is_not_hostile_or_primitive
							OR = {
								AND = {
									exists = space_owner
									space_owner = {
										merg_is_at_war = yes
									}
									is_artificial = no
								}
								AND = { # colony
									exists = owner
									owner = {
										merg_is_at_war = yes
									}
								}
								AND = { # primitive
									exists = space_owner
									exists = owner
									owner = {
										is_primitive = yes
									}
									space_owner = {
										merg_is_at_war = yes
									}
								}
							}
						}
					}
				}
			}
		"
		toggle = @has_tc_mod
	}
}
can_destroy_planet_with_TC_PLANET_KILLER_LIQUEFACTION_TURRET = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = tc_planet_killer_not_target
				NOR = {
					merg_is_shielded = yes
					is_asteroid = yes
					is_tc_invisible = yes
					is_tc_bedrock = yes
					is_planet_class = pc_ringworld_habitable_damaged
				}

				NOT = { has_planet_flag = tc_not_pk_target }
				is_star = no
			}
			custom_tooltip = {
				fail_text = tc_planet_killer_liquefaction_molten_target
				merg_is_molten = yes
			}
			custom_tooltip = {
				fail_text = tc_planet_killer_not_hostile
				OR = {
					AND = {
						custom_tooltip = {
							fail_text = tc_planet_killer_liquefaction_our_planet
							NOT = { exists = owner }
							exists = space_owner
							space_owner = { is_same_value = from.owner }
							is_artificial = no
						}
					}
					AND = {
						custom_tooltip = {
							fail_text = is_not_hostile_or_primitive
							OR = {
								AND = {
									exists = space_owner
									space_owner = {
										merg_is_at_war = yes
									}
									is_artificial = no
								}
								AND = { # colony
									exists = owner
									owner = {
										merg_is_at_war = yes
									}
								}
								AND = { # primitive
									exists = space_owner
									exists = owner
									owner = {
										is_primitive = yes
									}
									space_owner = {
										merg_is_at_war = yes
									}
								}
							}
						}
					}
				}
			}
		"
		toggle = @has_tc_mod
	}
}
can_destroy_planet_with_TC_PLANET_KILLER_DISINTEGRATION = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = tc_planet_killer_not_target
				NOR = {
					merg_is_shielded = yes
					is_asteroid = yes
					is_tc_invisible = yes
				}

				NOT = { has_planet_flag = tc_not_pk_target }
				is_star = no
			}
			custom_tooltip = {
				fail_text = tc_planet_killer_excavation_nothing_dig
				NOT = {
					is_tc_bedrock = yes
				}
			}
			custom_tooltip = {
				fail_text = tc_planet_killer_not_hostile
				OR = {
					AND = {
						custom_tooltip = {
							fail_text = tc_planet_killer_excavation_our_planet
							NOT = { exists = owner }
							exists = space_owner
							space_owner = { is_same_value = from.owner }
						}
					}
					AND = {
						custom_tooltip = {
							text = is_not_hostile_cracker
							OR = {
								AND = {
									exists = space_owner
									space_owner = {
										merg_is_at_war = yes
									}
								}
								AND = { # colony
									exists = owner
									owner = {
										merg_is_at_war = yes
									}
								}
								AND = { # primitive
									exists = space_owner
									exists = owner
									owner = {
										is_primitive = yes
									}
									space_owner = {
										merg_is_at_war = yes
									}
								}
							}
						}
					}
				}
			}
		"
		toggle = @has_tc_mod
	}
}
can_destroy_planet_with_TC_PLANET_KILLER_DISINTEGRATION_TURRET = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = tc_planet_killer_not_target
				NOR = {
					merg_is_shielded = yes
					is_asteroid = yes
					is_tc_invisible = yes
				}

				NOT = { has_planet_flag = tc_not_pk_target }
				is_star = no
			}
			custom_tooltip = {
				fail_text = tc_planet_killer_excavation_nothing_dig
				NOT = {
					is_tc_bedrock = yes
				}
			}
			custom_tooltip = {
				fail_text = tc_planet_killer_not_hostile
				OR = {
					AND = {
						custom_tooltip = {
							fail_text = tc_planet_killer_excavation_our_planet
							NOT = { exists = owner }
							exists = space_owner
							space_owner = { is_same_value = from.owner }
						}
					}
					AND = {
						custom_tooltip = {
							text = is_not_hostile_cracker
							OR = {
								AND = {
									exists = space_owner
									space_owner = {
										merg_is_at_war = yes
									}
								}
								AND = { # colony
									exists = owner
									owner = {
										merg_is_at_war = yes
									}
								}
								AND = { # primitive
									exists = space_owner
									exists = owner
									owner = {
										is_primitive = yes
									}
									space_owner = {
										merg_is_at_war = yes
									}
								}
							}
						}
					}
				}
			}
		"
		toggle = @has_tc_mod
	}
}
can_destroy_planet_with_TC_PLANET_KILLER_WARDING = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			OR = {
		AND = {
			custom_tooltip = {
				fail_text = tc_planet_killer_need_owner
				is_colony = yes
				exists = owner
				owner = { is_same_value = from.owner }
			}
		}
		AND = {
			custom_tooltip = {
				fail_text = tc_planet_killer_not_hostile
				OR = {
					AND = {
						exists = space_owner
						space_owner = {
							merg_is_at_war = yes
						}
					}
					AND = { # colony
						exists = owner
						owner = {
							merg_is_at_war = yes
						}
					}
					AND = { # primitive
						exists = space_owner
						exists = owner
						owner = {
							is_primitive = yes
						}
						space_owner = {
							merg_is_at_war = yes
						}
					}
				}
			}
		}
	}
		"
		toggle = @has_tc_mod
	}
}
can_destroy_planet_with_TC_PLANET_KILLER_WARDING_TURRET = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			OR = {
		AND = {
			custom_tooltip = {
				fail_text = tc_planet_killer_need_owner
				is_colony = yes
				exists = owner
				owner = { is_same_value = from.owner }
			}
		}
		AND = {
			custom_tooltip = {
				fail_text = tc_planet_killer_not_hostile
				OR = {
					AND = {
						exists = space_owner
						space_owner = {
							merg_is_at_war = yes
						}
					}
					AND = { # colony
						exists = owner
						owner = {
							merg_is_at_war = yes
						}
					}
					AND = { # primitive
						exists = space_owner
						exists = owner
						owner = {
							is_primitive = yes
						}
						space_owner = {
							merg_is_at_war = yes
						}
					}
				}
			}
		}
	}
		"
		toggle = @has_tc_mod
	}
}
can_destroy_planet_with_TC_PLANET_KILLER_CAVECREATER = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = tc_need_star
				is_star = yes
			}
			custom_tooltip = {
				fail_text = tc_invalid_target
				solar_system = {
					NOT = { has_star_flag = community_can_enter_system_by_jump_false }
				}
			}
		"
		toggle = @has_tc_mod
	}
}
can_destroy_planet_with_TC_PLANET_KILLER_MCV_DEPLOY = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = tc_need_star
				is_star = yes
			}
			custom_tooltip = {
				fail_text = tc_mcv_target_trigger
				solar_system = {
					OR = {
						NOT = { exists = owner }
						owner = {
							is_same_value = FROM.owner
						}
					}
				}
			}
		"
		toggle = @has_tc_mod
	}
}

############################### The Crimson Throng ###############################
can_destroy_planet_with_PLANET_KILLER_CLEANSER = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = must_do_sp_first
				NOT = { has_planet_flag = projcrim_sp_present }
			}
			OR = {
				custom_tooltip = {
					text = is_not_infected
					is_projcrim_afflicted = yes
				}
				custom_tooltip = {
					text = no_pops_infected
					any_owned_pop = {
						is_crimson_infected = yes
					}
				}
				custom_tooltip = {
					fail_text = controlled_by_throng
					exists = controller
					controller = {
						is_country_type = throng_country
					}
				}
			}
		"
		toggle = @crimson_throng_mod
	}
}

############################### The Empty Vagrant ###############################
can_destroy_planet_with_PLANET_KILLER_TAKING = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_standard_planet_or_megastructure
		is_a_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	OR = {
		custom_tooltip = {
			text = is_not_hostile_cracker
			OR = {
				AND = {
					NOT = {
						exists = owner
					}
					habitable_planet = yes
				}
				AND = {
					exists = space_owner
					space_owner = {
						merg_is_at_war = yes
					}
				}
				AND = {
					# colony
					exists = owner
					owner = {
						merg_is_at_war = yes
					}
				}
				AND = {
					# primitive
					exists = space_owner
					exists = owner
					owner = {
						is_primitive = yes
					}
					space_owner = {
						merg_is_at_war = yes
					}
				}
			}
		}
	}
}

############################### Eternal Empire ###############################
can_destroy_planet_with_EE_PLANETKILLER_GAIA = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_hostile
		OR = {
			AND = {
				#exists = space_owner
				space_owner = {
					OR = {
						is_same_value = from.owner
						merg_is_at_war = yes
					}
				}
			}
			AND = { # Ownelerless
				NOT = { exists = space_owner }
				NOT = { is_at_war_with = from.owner }
			}
			AND = { # primitive
				exists = space_owner
				exists = owner
				owner = { is_primitive = yes }
				space_owner = {
					merg_is_at_war = yes
				}
			}
		}
		NOT = {
			is_owned_by = event_target:origin_crisis_country
		}
		is_star = no
		is_asteroid = no
	}
}
can_destroy_planet_with_EE_PLANETKILLER_BARREN = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_hostile
		OR = {
			AND = {
				space_owner = {
					OR = {
						is_same_value = from.owner
						merg_is_at_war = yes
					}
				}
			}
			AND = {
				NOT = { exists = space_owner }
				NOT = { is_at_war_with = from.owner }
			}
			AND = {
				exists = space_owner
				exists = owner
				owner = { is_primitive = yes }
				space_owner = {
					merg_is_at_war = yes
				}
			}
		}
		NOT = { is_owned_by = event_target:origin_crisis_country }
		is_star = no
		is_asteroid = no
	}
}

############################### Twinks Kaldorei ###############################
can_destroy_planet_with_PLANET_KILLER_CRACKER_ARCANE = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_hostile
		OR = {
			AND = {
				space_owner = {
					OR = {
						is_same_value = from.owner
						merg_is_at_war = yes
					}
				}
			}
			AND = {
				NOT = { exists = space_owner }
				NOT = { is_at_war_with = from.owner }
			}
			AND = {
				exists = space_owner
				exists = owner
				owner = { is_primitive = yes }
				space_owner = { merg_is_at_war = yes }
			}
		}
		NOT = { is_owned_by = event_target:origin_crisis_country }
		is_star = no
		is_asteroid = no
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
}

############################### Warship Girls R And MIST Species ###############################
can_destroy_planet_with_PLANET_KILLER_OVO = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		is_a_habitable_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	custom_tooltip = {
		fail_text = is_not_hostile_or_primitive
		OR = {
			planet_is_hostile = yes
			AND = {
				exists = owner
				owner = { is_country_type = primitive }
			}
			AND = {
				exists = owner
				owner = { is_same_value = from.owner }
			}
		}
		if = {
			limit = {
				NOR = {
					planet_is_hostile = yes
					AND = {
						exists = owner
						owner = { is_country_type = primitive }
					}
				}
				exists = owner
				owner = { is_same_value = from.owner }
			}
			custom_tooltip = {
				text = not_owned_test_fire
				exists = owner
				owner = { is_same_value = from.owner }
			}
		}
	}
}
can_destroy_planet_with_PLANET_KILLER_PSH = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		is_a_habitable_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = is_shenhai
				NOT = { is_planet_class = pc_shenhai }
			}
			custom_tooltip = {
				fail_text = cannotdothis
				NOR = {
					merg_is_habitat = yes
					merg_is_hab_ringworld = yes
					is_planet_class = pc_habitat
				}
			}
			custom_tooltip = {
				fail_text = our_planet_only
				NOR = {
					planet_is_hostile = yes
					AND = {
						exists = owner
						owner = {
							is_country_type = primitive
						}
					}
				}
			}
		"
		toggle = @wsg_mod
	}
	if = {
		limit = {
			NOR = {
				planet_is_hostile = yes
				AND = {
					exists = owner
					owner = { is_country_type = primitive }
				}
			}
			exists = owner
			owner = { is_same_value = from.owner }
		}
		custom_tooltip = {
			text = not_owned_test_fire
			exists = owner
			owner = { is_same_value = from.owner }
		}
	}
}
can_destroy_planet_with_PLANET_KILLER_CM = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_not_a_habitable_planet_or_megastructure
		is_a_habitable_planet_megastructure = yes
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	custom_tooltip = {
		fail_text = is_not_hostile_or_primitive
		OR = {
			planet_is_hostile = yes
			AND = {
				exists = owner
				owner = { is_country_type = primitive }
			}
		}
	}
	if = {
		limit = {
			exists = owner
			owner = {
				is_country_type = primitive
			}
		}
		custom_tooltip = {
			fail_text = primitives_not_in_borders
			exists = space_owner
			space_owner = { is_same_value = from.owner }
		}
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = no_cm_pops
				any_owned_pop = {
					is_valid_pop_for_PLANET_KILLER_CM = yes
				}
			}
		"
		toggle = @wsg_mod
	}
}
can_destroy_planet_with_PLANET_KILLER_SK = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_untargetable = no
	}
	custom_tooltip = {
		fail_text = is_your_megastructure_system
		NOT = {
			solar_system = {
				has_star_flag = crisis_sphere_system@from.owner
				has_star_flag = wg_gateway_construction_system
				any_system_megastructure = { has_megastructure_flag = crisis_sphere }
				any_system_megastructure = { has_megastructure_flag = wg_fm_gateway }
			}
		}
	}
	custom_tooltip = {
		fail_text = is_shielded
		merg_is_shielded = no
	}
	custom_tooltip = {
		fail_text = star_owner_is_not_hostile
		OR = {
			NOT = { exists = space_owner }
			space_owner = { is_hostile = from.owner }
			space_owner = { is_same_value = from.owner }
		}
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = has_our_colony
				NOT = {
					solar_system = {
						any_system_planet = {
							exists = owner
							owner = { is_same_value = from.owner }
						}
					}
				}
			}
		"
		toggle = @wsg_mod
	}
	custom_tooltip = {
		fail_text = is_not_star
		is_star = yes
	}
	custom_tooltip = {
		fail_text = is_black_hole
		merg_is_black_or_white_hole = no
	}
}
can_destroy_planet_with_PLANET_KILLER_WATERB = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	OR = {
		hidden_trigger = {
			AND = {
				FROM = { has_fleet_flag = RBQ_Dragon_fleet }
				inline_script = {
					script = merger_of_rules/toggled_code
					code = "
						is_planet_class = pc_wg_water
					"
					toggle = @wsg_mod
				}
			}
		}
		AND = {
			custom_tooltip = {
				fail_text = is_not_a_standard_planet_or_megastructure
				is_a_planet_megastructure = yes
			}
			custom_tooltip = {
				fail_text = is_shielded
				merg_is_shielded = no
			}
			custom_tooltip = {
				inline_script = {
					script = merger_of_rules/toggled_code
					code = "
						fail_text = is_water_planet
						NOR = {
							is_planet_class = pc_wg_water
							is_planet_class = pc_ringworld_habitable_water
						}
					"
					toggle = @wsg_mod
				}
			}
			OR = {
				custom_tooltip = {
					fail_text = is_not_hostile_or_primitive
					OR = {
						planet_is_hostile = yes
						AND = {
							exists = owner
							owner = { is_country_type = primitive }
						}
					}
				}
				custom_tooltip = {
					text = not_barren_molten_frozen_toxic_test_fire
					NOT = { exists = owner }
					OR = {
						NOT = { exists = space_owner }
						AND = {
							exists = space_owner
							space_owner = { is_same_value = from.owner }
						}
					}
					merg_is_valid_for_test_fire = yes
				}
			}
		}
	}
}
wg_event_can_destroy_planet_with_PLANET_KILLER_CRACKER = { can_destroy_planet_with_PLANET_KILLER_CRACKER = yes }

############################### WULA Fallen Empire ###############################
can_destroy_planet_with_PLANET_KILLER_GENESIS = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	custom_tooltip = {
		fail_text = is_colony_of_someone
		is_colony = no
	}
	OR = {
		merg_is_hab_ringworld = yes
		merg_is_habitat = yes
		merg_is_basic_planet = yes
	}
	is_colonizable = yes
	custom_tooltip = {
		fail_text = has_been_sowed_by_genesis
		NOT = { has_planet_flag = has_been_sowed_by_genesis }
	}
	OR = {
		custom_tooltip = {
			text = is_not_hostile_cracker
			OR = {
				AND = {
					exists = space_owner
					space_owner = {
						merg_is_at_war = yes
					}
				}
				AND = { # colony
					exists = owner
					owner = {
						merg_is_at_war = yes
					}
				}
				AND = { # primitive
					exists = space_owner
					exists = owner
					owner = {
						is_primitive = yes
					}
					space_owner = {
						merg_is_at_war = yes
					}
				}
			}
		}
		custom_tooltip = {
			text = is_not_owned_or_claimed
			NOR = {
				exists = owner
				exists = space_owner
			}
		}
		custom_tooltip = {
			text = is_uninhabited_within_borders
			exists = space_owner
			space_owner = { is_same_value = from.owner }
			is_colony = no
		}
	}
}
can_destroy_planet_with_PLANET_KILLER_IDC = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_forbidden_target = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = is_not_a_default_empire_colony
				is_colony = yes
				owner = { merg_is_default_empire = yes }
			}
			custom_tooltip = {
				fail_text = has_another_IDC_in_system
				solar_system = {
					NOT = { any_fleet_in_system = { is_ship_size = IDC_station_fallen_empire } }
				}
			}
		"
		toggle = @wula_compatch_var
	}
}
can_destroy_planet_with_PLANET_KILLER_Pilgrimage = {
	custom_tooltip = {
		fail_text = merg_forbidden_target
		merg_is_untargetable = no
	}
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = can_only_deploy_on_star
				is_star = yes
			}
			custom_tooltip = {
				fail_text = can_not_deploy_near_other_empire
				solar_system = { any_neighbor_system = { NOT = { exists = owner } } }
			}
			custom_tooltip = {
				fail_text = can_not_deploy_if_system_owned
				solar_system = { NOT = { exists = owner } }
			}
		"
		toggle = @wula_compatch_var
	}
}

# ===========================================================================================================================

# PK Triggers here
# Vanilla triggers
can_destroy_planet_general = {
	is_star = no
	is_astral_scar = no
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			giga_is_birch_world = no
		"
		toggle = @has_gigastructures
	}
	OR = {
		NOT = { exists = owner }
		owner = { is_hostile = from.owner }
	}
}
is_a_planet = {
	optimize_memory
	is_star = no
	NOR = {
		is_artificial = yes
		is_asteroid = yes
		merg_is_gas_giant = yes
		is_planet_class = pc_shrouded
	}
}
is_a_planet_megastructure = {
	optimize_memory
	is_star = no
	NOR = {
		merg_is_gas_giant = yes
		is_asteroid = yes
		is_planet_class = pc_shrouded
		merg_is_broken = yes
		has_planet_flag = has_arc_furnace
		# Additional Mega-Engineering Projects
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				has_planet_flag = has_epam_planet_mega
			"
			toggle = @has_epam_mod
		}
	}
}

# Turning this into a dynamic trigger
planet_is_hostile_or_crisis = {
	exists = owner
	owner = {
		OR = {
			is_at_war_with = from.owner
			is_crisis_faction = yes
			# Aggressive Crisis Engine
			from.owner = {
				is_hostile = prev # Fix for empires which cannot be at war (crises).
				OR = {
					has_country_flag = acemod_can_target_hostile_with_colossus # Fallback flag in case needed.
					is_crisis_faction = yes # Narrow down to just crises as to not alter more than needed.
				}
			}
			# Safety Off
			AND = {
				merg_has_safety_off = yes
				is_same_value = from.owner
			}
		}
	}
}
merg_planet_is_hostile_or_crisis = {
	optimize_memory
	OR = {
		planet_is_hostile_or_crisis = yes
		# Safety Off
		AND = {
			merg_has_safety_off = yes
			is_same_value = from.owner
		}
	}
}
is_a_habitable_planet_megastructure = {
	OR = {
		colonizable_planet = yes
		habitable_structure = yes
		is_planet_class = pc_infested
		# ACOT
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				is_acot_fractured_planet_class = yes
				is_acot_awesome_planet_class = yes
			"
			toggle = @has_ancient_caches
		}
		# Misc
		merg_is_nuked = yes
		# Planetary Diversity
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				pd_is_planet_class_all = yes
			"
			toggle = @has_planetary_diversity
		}
	}
}
merg_is_at_war = {
	optimize_memory
	OR = {
		is_at_war_with = from.owner
		is_crisis_faction = yes
		# Aggressive Crisis Engine
		from.owner = {
			is_hostile = prev
			OR = {
				has_country_flag = acemod_can_target_hostile_with_colossus
				is_crisis_faction = yes
			}
		}
		# Safety Off
		AND = {
			merg_has_safety_off = yes
			is_same_value = from.owner
		}
	}
}
merg_is_untargetable = {
	optimize_memory
	OR = {
		is_astral_scar = yes
		# MEM
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				is_pc_mem_synthetic_sun = yes
			"
			toggle = @has_more_events_mod
		}
		# ACOT
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				is_acot_awesome_planet_class = yes
				is_acot_pmc_vault = yes
				is_acot_void_hole = yes
			"
			toggle = @has_ancient_caches
		}
		# Darkspace
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				is_ds_holosphere = yes
				is_ds_stellar_engine = yes
				is_ds_gc_star = yes
			"
			toggle = @has_darkspace_installed
		}
		# Gigastructural Engineering & More
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				has_planet_flag = ndb_immune_planet
				has_planet_flag = cant_build_here
				giga_is_pc_ehof_cplanet = yes
				giga_is_birch_world = yes
			"
			toggle = @has_gigastructures
		}
		# Secrets of the Shroud
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				is_sots_soulsphere = yes
			"
			toggle = @has_sots_mod
		}
		# Sparble's Stellar Hyperconstructs
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				is_planet_class = pc_exodus_portal
			"
			toggle = @has_stellar_hyperconstructs
		}
		# ThaumStellaris
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				has_planet_flag = tc_not_pk_target
			"
			toggle = @has_tc_mod
		}
		# Voyage to Eternity
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				KZ_VOY_can_not_destroy_by_planet_killer = yes
			"
			toggle = @vte_mod
		}
		# Merger of Rules
		has_planet_flag = merg_is_forbidden_target		# add this to your planet to dynamically exclude it.
		has_planet_flag = merg_forbidden_target			# or this one.
	}
}

# Used by Planet Killers to forbid them to destroy invalid targets
merg_is_forbidden_target = {
	optimize_memory
	OR = {
		merg_is_dense_star = yes
		merg_is_empty_space = yes
		merg_is_untargetable = yes
	}
}
merg_is_valid_for_test_fire = {
	OR = {
		colonizable_planet = yes
		is_artificial = yes
		uninhabitable_regular_planet = yes
		merg_has_safety_off = yes
	}
}
