﻿on_raid_action_completion = { on_actions = { MTXXX_on_raid_action_completion } }

MTXXX_on_raid_action_completion = {
	trigger = {
		scope:raider.culture = { has_cultural_tradition = tradition_raiders_of_the_lost }
	}
	effect = {
		scope:raider = {
			trigger_event = MTXXX_raiding.0010
		}
	}
}

# Happens when a culture is created through hybridization or divergence
# Root = The new culture
# scope:founder = The founder of the new culture
on_culture_created = { on_actions = { mtxxx_on_culture_created } }

mtxxx_on_culture_created = {
	effect = {
		save_scope_value_as = { name = mtxxx_number_of_innovations value = 0 }
		save_scope_value_as = { name = mtxxx_max_innovation value = 0 }

		if = {
			limit = {
				has_innovation = innovation_mtxxx_slots_1
			}

			save_scope_value_as = { name = mtxxx_number_of_innovations value = { value = scope:mtxxx_number_of_innovations add = 1 } }
			save_scope_value_as = { name = mtxxx_max_innovation value = 1 }
		}

		if = {
			limit = {
				has_innovation = innovation_mtxxx_slots_5
			}

			save_scope_value_as = { name = mtxxx_number_of_innovations value = { value = scope:mtxxx_number_of_innovations add = 1 } }
			save_scope_value_as = { name = mtxxx_max_innovation value = 5 }
		}

		if = {
			limit = {
				has_innovation = innovation_mtxxx_slots_10
			}

			save_scope_value_as = { name = mtxxx_number_of_innovations value = { value = scope:mtxxx_number_of_innovations add = 1 } }
			save_scope_value_as = { name = mtxxx_max_innovation value = 10 }
		}

		if = {
			limit = {
				has_innovation = innovation_mtxxx_slots_20
			}

			save_scope_value_as = { name = mtxxx_number_of_innovations value = { value = scope:mtxxx_number_of_innovations add = 1 } }
			save_scope_value_as = { name = mtxxx_max_innovation value = 20 }
		}

		if = {
			limit = {
				scope:mtxxx_number_of_innovations > 0
			}

			switch = {
				trigger = scope:mtxxx_max_innovation
				5 = {
					remove_innovation = innovation_mtxxx_slots_1
				}
				10 = {
					remove_innovation = innovation_mtxxx_slots_1
					remove_innovation = innovation_mtxxx_slots_5
				}
				20 = {
					remove_innovation = innovation_mtxxx_slots_1
					remove_innovation = innovation_mtxxx_slots_5
					remove_innovation = innovation_mtxxx_slots_10
				}
			}
		}
	}
}
