####################
# MARAUDER TRIBUTES
####################

@tributeallow1 = 250
@tributeallow2 = 500
@tributeallow3 = 1000
@tributeallow4 = 1500
@tributeallow5 = 2000
@tributeallow6 = 2500

@tributeallowraided1 = 500
@tributeallowraided2 = 1000
@tributeallowraided3 = 2000
@tributeallowraided4 = 3000
@tributeallowraided5 = 4000
@tributeallowraided6 = 5000

determine_energy_tribute = {
	if = {
		limit = { has_country_flag = marauder_tribute_6@event_target:raiding_marauder }
		resource_stockpile_compare = { resource = energy value >= @tributeallow6 }
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_5@event_target:raiding_marauder }
		resource_stockpile_compare = { resource = energy value >= @tributeallow5 }
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_4@event_target:raiding_marauder }
		resource_stockpile_compare = { resource = energy value >= @tributeallow4 }
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_3@event_target:raiding_marauder }
		resource_stockpile_compare = { resource = energy value >= @tributeallow3 }
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_2@event_target:raiding_marauder }
		resource_stockpile_compare = { resource = energy value >= @tributeallow2 }
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_1@event_target:raiding_marauder }
		resource_stockpile_compare = { resource = energy value >= @tributeallow1 }
	}
}

determine_mineral_tribute = {
	if = {
		limit = { has_country_flag = marauder_tribute_6@event_target:raiding_marauder }
		resource_stockpile_compare = { resource = minerals value >= @tributeallow6 }
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_5@event_target:raiding_marauder }
		resource_stockpile_compare = { resource = minerals value >= @tributeallow5 }
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_4@event_target:raiding_marauder }
		resource_stockpile_compare = { resource = minerals value >= @tributeallow4 }
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_3@event_target:raiding_marauder }
		resource_stockpile_compare = { resource = minerals value >= @tributeallow3 }
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_2@event_target:raiding_marauder }
		resource_stockpile_compare = { resource = minerals value >= @tributeallow2 }
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_1@event_target:raiding_marauder }
		resource_stockpile_compare = { resource = minerals value >= @tributeallow1 }
	}
}

determine_food_tribute = {
	if = {
		limit = { has_country_flag = marauder_tribute_6@event_target:raiding_marauder }
		resource_stockpile_compare = { resource = food value >= @tributeallow6 }
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_5@event_target:raiding_marauder }
		resource_stockpile_compare = { resource = food value >= @tributeallow5 }
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_4@event_target:raiding_marauder }
		resource_stockpile_compare = { resource = food value >= @tributeallow4 }
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_3@event_target:raiding_marauder }
		resource_stockpile_compare = { resource = food value >= @tributeallow3 }
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_2@event_target:raiding_marauder }
		resource_stockpile_compare = { resource = food value >= @tributeallow2 }
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_1@event_target:raiding_marauder }
		resource_stockpile_compare = { resource = food value >= @tributeallow1 }
	}
}

determine_energy_tribute_raided = {
	if = {
		limit = { has_country_flag = marauder_tribute_6@event_target:marauder_country }
		resource_stockpile_compare = {
			resource = energy
			value >= @tributeallowraided6
		}
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_5@event_target:marauder_country }
		resource_stockpile_compare = {
			resource = energy
			value >= @tributeallowraided5
		}
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_4@event_target:marauder_country }
		resource_stockpile_compare = {
			resource = energy
			value >= @tributeallowraided4
		}
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_3@event_target:marauder_country }
		resource_stockpile_compare = {
			resource = energy
			value >= @tributeallowraided3
		}
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_2@event_target:marauder_country }
		resource_stockpile_compare = {
			resource = energy
			value >= @tributeallowraided2
		}
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_1@event_target:marauder_country }
		resource_stockpile_compare = {
			resource = energy
			value >= @tributeallowraided1
		}
	}
	else = {
		resource_stockpile_compare = {
			resource = energy
			value >= @tributeallowraided1
		}
	}
}

determine_mineral_tribute_raided = {
	if = {
		limit = { has_country_flag = marauder_tribute_6@event_target:marauder_country }
		resource_stockpile_compare = {
			resource = minerals
			value >= @tributeallowraided6
		}
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_5@event_target:marauder_country }
		resource_stockpile_compare = {
			resource = minerals
			value >= @tributeallowraided5
		}
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_4@event_target:marauder_country }
		resource_stockpile_compare = {
			resource = minerals
			value >= @tributeallowraided4
		}
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_3@event_target:marauder_country }
		resource_stockpile_compare = {
			resource = minerals
			value >= @tributeallowraided3
		}
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_2@event_target:marauder_country }
		resource_stockpile_compare = {
			resource = minerals
			value >= @tributeallowraided2
		}
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_1@event_target:marauder_country }
		resource_stockpile_compare = {
			resource = minerals
			value >= @tributeallowraided1
		}
	}
	else = {
		resource_stockpile_compare = {
			resource = minerals
			value >= @tributeallowraided1
		}
	}
}

determine_food_tribute_raided = {
	if = {
		limit = { has_country_flag = marauder_tribute_6@event_target:marauder_country }
		resource_stockpile_compare = {
			resource = food
			value >= @tributeallowraided6
		}
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_5@event_target:marauder_country }
		resource_stockpile_compare = {
			resource = food
			value >= @tributeallowraided5
		}
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_4@event_target:marauder_country }
		resource_stockpile_compare = {
			resource = food
			value >= @tributeallowraided4
		}
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_3@event_target:marauder_country }
		resource_stockpile_compare = {
			resource = food
			value >= @tributeallowraided3
		}
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_2@event_target:marauder_country }
		resource_stockpile_compare = {
			resource = food
			value >= @tributeallowraided2
		}
	}
	else_if = {
		limit = { has_country_flag = marauder_tribute_1@event_target:marauder_country }
		resource_stockpile_compare = {
			resource = food
			value >= @tributeallowraided1
		}
	}
	else = {
		resource_stockpile_compare = {
			resource = food
			value >= @tributeallowraided1
		}
	}
}

##########################
# OTHER MARAUDER TRIGGERS
##########################

# Country scope
has_marauder_event = {
	has_active_event = {
		# Introductions & menus (all 3 clans)
		marauder.15		# introduction
		marauder.19		# refusing comms.
		marauder.20		# initial menu
		marauder.21		# main menu
		marauder.102	# while being spontaneously raided
		marauder.112	# while being raided under contract
		# Raid another Empire
		marauder.31		# raid a Rival
		marauder.32		# confirm purchase
		marauder.35		# attempting to raid a Fallen Empire
		marauder.101	# announcing a raid
		# Hire a Leader
		marauder.40
		# Hire mercenary Fleet
		marauder.34		# hire a Fleet
		marauder.37		# confirm purchase
		marauder.86		# Marauders 1 fleet available
		marauder.87		# Marauders 2 fleet available
		marauder.88		# Marauders 3 fleet available
		# Other
		marauder.111	# Raiders withdrawing from your space
		marauder.121	# transmission from raiders on approach
		marauder.7		# Marauder clan declares vengeance
	}
}

has_khan_event = {
	has_active_event = {
		marauder.502	# announcement following "Drums of War"
		marauder.508	# return of the Great Khan
		marauder.550	# main menu
		marauder.551	# submit to the Khan
		marauder.554	# defy the Khan
		marauder.665	# Khan menu (deceased)
	}
}

is_marauder_empire = {
	OR = {
		is_country_type = dormant_marauders
		is_country_type = marauder_raiders
		is_country_type = awakened_marauders
	}
}
