
ap_plnmg_organic_raid = {
	potential = {
		is_ai = no
		NOR = {
			has_ascension_perk = ap_plnmg_organic_raid
			is_slaver = yes
		}
		has_technology = tech_planetmega_improved
		### from "possible" entry of ap_nihilistic_acquisition ###
		NOR = {
			#强取豪夺
			is_authoritarian = yes
			is_xenophobe = yes
			is_gestalt = yes
			#移居
			# is_pacifist = yes
			# is_egalitarian = yes
			# is_xenophile = yes
		}
	}

	on_enabled = {
		custom_tooltip = "allow_plnmg_organic_raiding"
	}

	possible = {
		OR = {
			is_nomadic = yes
			is_militarist = yes
			has_civic = civic_barbaric_despoilers
			hidden_trigger = {
				or = {
					has_origin = origin_slavers
					has_origin = origin_khan_successor
				}
			}
		}
	}

	ai_weight = {
		factor = 0 #10
		# modifier = {
		# 	factor = 0
		# 	NOR = {
		# 		has_ai_personality_behaviour = purger
		# 		has_ai_personality_behaviour = displacer
		# 	}
		# }
	}
}

# ap_plnmg_organic_resettle = {
# 	potential = {
# 		is_ai = no
# 		NOR = {
# 			has_ascension_perk = ap_plnmg_organic_raid
# 			has_ascension_perk = ap_nihilistic_acquisition
# 			has_ascension_perk = ap_plnmg_organic_resettle
# 		}
# 		has_technology = tech_planetmega_improved
# 		### from "possible" entry of ap_nihilistic_acquisition ###
# 		NOR = {
# 			#强取豪夺
# 			is_authoritarian = yes
# 			is_xenophobe = yes
# 			is_gestalt = yes
# 			#开源
# 			is_militarist = yes
# 			has_valid_civic = civic_barbaric_despoilers
# 			has_origin = origin_slavers
# 			has_origin = origin_khan_successor
# 		}
# 	}
#
# 	on_enabled = {
# 		custom_tooltip = "allow_plnmg_organic_raiding"
# 	}
#
# 	possible = {
# 		OR = {
# 			is_pacifist = yes
# 			is_egalitarian = yes
# 			is_xenophile = yes
# 		}
# 	}
#
# 	ai_weight = {
# 		factor = 0 #10
# 		modifier = {
# 			factor = 0
# 			NOR = {
# 				has_ai_personality_behaviour = purger
# 				has_ai_personality_behaviour = displacer
# 			}
# 		}
# 	}
# }

ap_planetmega_advanced = {
	potential = {
		is_ai = no
		ready2rickroll = no
		nor = {
			has_global_flag = planetmega_advanced_banned
			has_ascension_perk = ap_planetmega_advanced
			has_ascension_perk = ap_planetmega_advanced_rickroll
			#has_technology = tech_planetmega_advanced
		}
	}
	possible = {
		has_technology = tech_planetmega_improved
		has_technology = tech_mega_engineering
		custom_tooltip = {
			fail_text = requires_5_t5_researched_techs
			num_researched_techs_of_tier = { tier = 5 value >= 5 }
		}
		custom_tooltip = {
			fail_text = "requires_ascension_perks_1"
			num_ascension_perks > 0
		}
	}

	on_enabled = {
		custom_tooltip = allow_planetmega_advanced
		hidden_effect = {
            random = {
                chance = 42
                add_research_option = tech_planetmega_advanced
            }
		}
	}

    modifier = {
        ground_megastructure_build_speed_mult = 0.15
        planetmega_job_amount_mult = 0.1
        ground_megastructure_build_cap_add = 1
        planetmega_space_need_mult = -0.1
		#country_megastructure_build_cap_add = 1
    }

	ai_weight = { weight = 0 }
}
ap_planetmega_advanced_rickroll = {
	potential = {
		is_ai = no
		ready2rickroll = yes
		nor = {
			has_global_flag = planetmega_advanced_banned
			has_ascension_perk = ap_planetmega_advanced
			has_ascension_perk = ap_planetmega_advanced_rickroll
			#has_technology = tech_planetmega_advanced
		}
	}
	possible = {
		has_technology = tech_planetmega_improved
		has_technology = tech_mega_engineering
	}

	on_enabled = {
		custom_tooltip = allow_planetmega_advanced_rickroll
		hidden_effect = {
			country_event = { id = planetmega_easter.10 }
			remove_ascension_perk = ap_planetmega_advanced_rickroll
			if = {
				limit = {
					num_ascension_perks > 0
					num_researched_techs_of_tier = { tier = 5 value > 4 }
				}
				add_ascension_perk = ap_planetmega_advanced
			}
		}
	}

	ai_weight = { weight = 0 }
}
