﻿# Exact compatibility bridge for More Events Mod 2.20.0 / Stellaris 4.5.*.
# Called only after MEM's persistent mem_more_events_mod marker is present.
asp_mem_220_apply_compatibility = {
	# Native MEM 2.20.0 entry guards for the ASP stories that MEM still schedules.
	set_global_flag = mem_scfe_had_soulofarts
	set_global_flag = mem_scfe_had_kingunderground
	set_global_flag = arc_mem_scfe_when_the_world_sings
	set_global_flag = mem_scfe_had_tombdeadwhales

	# Old MEM saves can own the legacy Geocentric technology/relic identities.
	# Migrate them to the standalone ASP implementation so the effective
	# PLANET_KILLER_GEOCENTRIC_DEVICE prerequisite stays coherent.
	if = {
		limit = { has_relic = r_mem_aspmod_geocentric_device }
		# The MEM reward always carried the legacy relic. Use that defined alias as the
		# migration sentinel so standalone ASP never references an undefined MEM tech key.
		if = {
			limit = { NOT = { has_relic = r_aspmod_geocentric_device } }
			add_relic = r_aspmod_geocentric_device
		}
		if = {
			limit = {
				host_has_dlc = Apocalypse
				NOT = { has_technology = tech_aspmod_geocentric_device }
			}
			give_technology = { tech = tech_aspmod_geocentric_device message = no }
		}
		remove_relic = r_mem_aspmod_geocentric_device
	}

	set_global_flag = asp_mem_compat_active
}
