
#Massive Tribute paid
tribute_mission_expanded_deadline_years = 20

#Default: Pay Tribute once every 15 years, or else...
tribute_mission_deadline_years = 15

#Sorry Tribute paid
tribute_mission_frequent_deadline_years = 10

#... but not too often?
tribute_mission_cooldown_years = 5
tribute_mission_cooldown_more_years = 10
tribute_mission_cooldown_most_years = 15

#Requested Tribute
requested_tribute_mission_deadline_years = 5

tribute_reward_innovation_progress_value = 5
tribute_reward_fascination_progress_value = 5

tribute_seal_of_investiture_cost = 500

exact_tribute_subject_standing_value = 20

tribute_reward_treasury_cost = {
	value = 0
	add = minor_treasury_value
}

seal_of_investiture_minimum_subject_standing = {
	if = { 
		limit = { exists = scope:tributary_scope }
		scope:tributary_scope = {
			save_temporary_scope_as = tributary_temp
		}
	}
	else = {
		save_temporary_scope_as = tributary_temp
	}
	scope:tributary_temp = {
		if = {
			limit = { highest_held_title_tier >= tier_kingdom }
			value = 30
		}
		else_if = {
			limit = { highest_held_title_tier >= tier_duchy }
			value = 50
		}
		else_if = {
			limit = { highest_held_title_tier >= tier_county }
			value = 70
		}
	}
}

tribute_mission_seal_of_investiture_ai_will_select = {
	if = { 
		limit = { exists = scope:tributary_scope }
		scope:tributary_scope = {
			save_temporary_scope_as = tributary_temp
		}
	}
	else = {
		save_temporary_scope_as = tributary_temp
	}
	add = scope:tributary_temp.subject_standing
	save_temporary_value_as = current_standing
	if = {
		limit = { scope:current_standing < scope:tributary_temp.seal_of_investiture_minimum_subject_standing }
		value = 0
	}
	else = {
		subtract = scope:tributary_temp.seal_of_investiture_minimum_subject_standing
		if = {
			limit = { exists = scope:successful_influence } # This is not counted into the chance when assessing before the mission
			add = 25
		}
		overlord ?= {
			add = {
				add = ai_greed
				multiply = -0.5
			}
			add = {
				add = ai_honor
				multiply = 0.5
			}
		}
	}
}

tribute_mission_no_seal_of_investiture_ai_will_select = {
	if = {
		limit = { tribute_mission_seal_of_investiture_ai_will_select >= 100 }
		value = 0
	}
	else = {
		value = 10
	}
}

tribute_mission_chance_to_receive_seal_of_investiture = {
	if = {
		limit = { overlord ?= { is_ai = no } }
		value = -1 # uncertain
	}
	else = {
		value = tribute_mission_seal_of_investiture_ai_will_select
		save_temporary_value_as = base_chance 
		divide = {
			add = scope:base_chance
			add = tribute_mission_no_seal_of_investiture_ai_will_select
		}
		min = 0
	}
}

tribute_reward_treasury_cap = {
	value = excessive_gold_tribute_value
	multiply = 2
	culture ?= {
		if = {
			limit = {
				has_cultural_era_or_later = culture_era_late_medieval
			}
			multiply = 1.6
		}
		else_if = {
			limit = {
				has_cultural_era_or_later = culture_era_high_medieval
			}
			multiply = 1.4
		}
		else_if = {
			limit = {
				has_cultural_era_or_later = culture_era_early_medieval
			}
			multiply = 1.2
		}
		else = {
			multiply = 1
		}
	}
}

tribute_treasury_reward_value = {
	value = 0
	if = {
		limit = { 
			scope:tributary_scope = { has_variable = offered_gold_value }
		}
		value = scope:tributary_scope.var:offered_gold_value
	}
	else = {
		value = tribute_reward_treasury_cost
	}
	multiply = 3
	multiply = {
		value = scope:opinion_of_tributary
		divide = 5
		min = 1
	}
	min = tribute_reward_treasury_cost
	max = tribute_reward_treasury_cap
}

small_herd_tribute_value = {
	value = minor_herd_value_no_dominance
	multiply = gold_to_herd_conversion_rate
	floor = yes
	min = 50
}

adequate_herd_tribute_value = {
	value = major_herd_value_no_dominance
	multiply = gold_to_herd_conversion_rate
	floor = yes
	min = 200
}

excessive_herd_tribute_value = {
	value = massive_herd_value_no_dominance
	multiply = gold_to_herd_conversion_rate
	floor = yes
	min = 500
}

herd_conversion_tribute_value = {
	value = 0
	add = scope:tributary_scope.var:offered_herd_value
	divide = gold_to_herd_conversion_rate
}

small_gold_tribute_value = {
	if = {
		limit = { is_tributary = no }
		if = {
			limit = {
				OR = {
					has_variable = wants_to_become_tributary_of_china
					any_neighboring_top_liege_realm_owner = {
						primary_title = title:h_china
					}
				}
			}
			title:h_china.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else_if = {
			limit = {
				any_neighboring_top_liege_realm_owner = {
					primary_title = title:h_roman_empire
				}
			}
			title:h_roman_empire.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else_if = {
			limit = {
				any_neighboring_top_liege_realm_owner = {
					primary_title = title:h_eastern_roman_empire
				}
			}
			title:h_eastern_roman_empire.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else_if = {
			limit = {
				any_neighboring_top_liege_realm_owner = {
					primary_title = title:h_dar_al_islam
				}
			}
			title:h_dar_al_islam.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else_if = {
			limit = {
				any_neighboring_top_liege_realm_owner = {
					primary_title = title:h_india
				}
			}
			title:h_india.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else_if = {
			limit = {
				any_neighboring_top_liege_realm_owner = {
					primary_title = title:h_europa
				}
			}
			title:h_europa.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else_if = {
			limit = {
				any_neighboring_top_liege_realm_owner = {
					primary_title = title:h_numenor
				}
			}
			title:h_numenor.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		#For Exact Tribute rolling error
		else_if = {
			limit = { exists = scope:actor }
			scope:actor = { save_temporary_scope_as = tribute_target }
		}
		else = {
			suzerain ?= { save_temporary_scope_as = tribute_target } #Temporary error fix until widgets are evaluated after is_shown on decisions TIT-67694
		}
	}
	else = {
		suzerain ?= { save_temporary_scope_as = tribute_target }
	}
	value = 0
	if = {
		limit = {
			scope:tribute_target = { has_treasury = yes }
		}
		add = minor_treasury_value
	}
	else = {
		add = minor_gold_value
	}
	if = {
		limit = {
			scope:tribute_target = {
				has_any_worst_bad_relationship_with_character_trigger = { CHARACTER = prev }
			}
		}
		multiply = 1.5
	}
	else_if = {
		limit = {
			scope:tribute_target = {
				has_any_bad_relationship_with_character_trigger = { CHARACTER = prev }
			}
		}
		multiply = 1.25
	}
	max = {
		scope:tribute_target.culture = {
			if = {
				limit = {
					has_cultural_era_or_later = culture_era_late_medieval
				}
				value = 200
			}
			else_if = {
				limit = {
					has_cultural_era_or_later = culture_era_high_medieval
				}
				value = 150
			}
			else_if = {
				limit = {
					has_cultural_era_or_later = culture_era_early_medieval
				}
				value = 100
			}
			else_if = {
				limit = {
					has_cultural_era_or_later = culture_era_tribal
				}
				value = 50
			}
			else = {
				value = 25
			}
		}
	}
	floor = yes
	if = {
		limit = { scope:tribute_target = { highest_held_title_tier = tier_hegemony } }
		if = {
			limit = { primary_title.tier >= tier_empire }
			min = 100
		}
		else_if = {
			limit = { primary_title.tier >= tier_kingdom }
			min = 75
		}
		else = { min = 50 }
	}
	else = { min = 5 }
}

adequate_gold_tribute_value = {
	if = {
		limit = { is_tributary = no }
		if = {
			limit = {
				OR = {
					has_variable = wants_to_become_tributary_of_china
					any_neighboring_top_liege_realm_owner = {
						primary_title = title:h_china
					}
				}
			}
			title:h_china.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else_if = {
			limit = {
				any_neighboring_top_liege_realm_owner = {
					primary_title = title:h_roman_empire
				}
			}
			title:h_roman_empire.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else_if = {
			limit = {
				any_neighboring_top_liege_realm_owner = {
					primary_title = title:h_eastern_roman_empire
				}
			}
			title:h_eastern_roman_empire.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else_if = {
			limit = {
				any_neighboring_top_liege_realm_owner = {
					primary_title = title:h_dar_al_islam
				}
			}
			title:h_dar_al_islam.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else_if = {
			limit = {
				any_neighboring_top_liege_realm_owner = {
					primary_title = title:h_india
				}
			}
			title:h_india.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else_if = {
			limit = {
				any_neighboring_top_liege_realm_owner = {
					primary_title = title:h_europa
				}
			}
			title:h_europa.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else_if = {
			limit = {
				any_neighboring_top_liege_realm_owner = {
					primary_title = title:h_numenor
				}
			}
			title:h_numenor.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else = {
			suzerain ?= { save_temporary_scope_as = tribute_target } #Temporary error fix until widgets are evaluated after is_shown on decisions TIT-67694
		}
	}
	else = {
		suzerain ?= { save_temporary_scope_as = tribute_target }
	}
	value = 0
	if = {
		limit = {
			scope:tribute_target = { has_treasury = yes }
		}
		add = major_treasury_value
	}
	else = {
		add = major_gold_value
	}
	if = {
		limit = {
			scope:tribute_target = {
				has_any_worst_bad_relationship_with_character_trigger = { CHARACTER = prev }
			}
		}
		multiply = 1.5
	}
	else_if = {
		limit = {
			scope:tribute_target = {
				has_any_bad_relationship_with_character_trigger = { CHARACTER = prev }
			}
		}
		multiply = 1.25
	}
	max = {
		scope:tribute_target = {
			culture ?= {
				if = {
					limit = {
						has_cultural_era_or_later = culture_era_late_medieval
					}
					value = 300
				}
				else_if = {
					limit = {
						has_cultural_era_or_later = culture_era_high_medieval
					}
					value = 250
				}
				else_if = {
					limit = {
						has_cultural_era_or_later = culture_era_early_medieval
					}
					value = 200
				}
				else_if = {
					limit = {
						has_cultural_era_or_later = culture_era_tribal
					}
					value = 100
				}
				else = {
					value = 50
				}
			}
		}
	}
	floor = yes
	if = {
		limit = { scope:tribute_target = { highest_held_title_tier = tier_hegemony } }
		if = {
			limit = { primary_title.tier >= tier_empire }
			min = 150
		}
		else_if = {
			limit = { primary_title.tier >= tier_kingdom }
			min = 100
		}
		else = { min = 75 }
	}
	else = { min = 5 }
}

excessive_gold_tribute_value = {
	if = {
		limit = { is_tributary = no }
		if = {
			limit = {
				OR = {
					has_variable = wants_to_become_tributary_of_china
					any_neighboring_top_liege_realm_owner = {
						primary_title = title:h_china
					}
				}
			}
			title:h_china.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else_if = {
			limit = {
				any_neighboring_top_liege_realm_owner = {
					primary_title = title:h_roman_empire
				}
			}
			title:h_roman_empire.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else_if = {
			limit = {
				any_neighboring_top_liege_realm_owner = {
					primary_title = title:h_eastern_roman_empire
				}
			}
			title:h_eastern_roman_empire.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else_if = {
			limit = {
				any_neighboring_top_liege_realm_owner = {
					primary_title = title:h_dar_al_islam
				}
			}
			title:h_dar_al_islam.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else_if = {
			limit = {
				any_neighboring_top_liege_realm_owner = {
					primary_title = title:h_india
				}
			}
			title:h_india.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else_if = {
			limit = {
				any_neighboring_top_liege_realm_owner = {
					primary_title = title:h_europa
				}
			}
			title:h_europa.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else_if = {
			limit = {
				any_neighboring_top_liege_realm_owner = {
					primary_title = title:h_numenor
				}
			}
			title:h_numenor.holder = {
				save_temporary_scope_as = tribute_target
			}
		}
		else = {
			suzerain ?= { save_temporary_scope_as = tribute_target } #Temporary error fix until widgets are evaluated after is_shown on decisions TIT-67694
		}
	}
	else = {
		suzerain ?= { save_temporary_scope_as = tribute_target }
	}
	value = 0
	if = {
		limit = {
			scope:tribute_target = { has_treasury = yes }
		}
		add = massive_treasury_value
	}
	else = {
		add = massive_gold_value
	}
	if = {
		limit = {
			scope:tribute_target = {
				has_any_worst_bad_relationship_with_character_trigger = { CHARACTER = prev }
			}
		}
		multiply = 1.5
	}
	else_if = {
		limit = {
			scope:tribute_target = {
				has_any_bad_relationship_with_character_trigger = { CHARACTER = prev }
			}
		}
		multiply = 1.25
	}
	max = {
		scope:tribute_target.culture = {
			if = {
				limit = {
					has_cultural_era_or_later = culture_era_late_medieval
				}
				value = 450
			}
			else_if = {
				limit = {
					has_cultural_era_or_later = culture_era_high_medieval
				}
				value = 325
			}
			else_if = {
				limit = {
					has_cultural_era_or_later = culture_era_early_medieval
				}
				value = 250
			}
			else_if = {
				limit = {
					has_cultural_era_or_later = culture_era_tribal
				}
				value = 150
			}
			else = {
				value = 75
			}
		}
	}
	floor = yes
	if = {
		limit = { scope:tribute_target = { highest_held_title_tier = tier_hegemony } }
		if = {
			limit = { primary_title.tier >= tier_empire }
			min = 250
		}
		else_if = {
			limit = { primary_title.tier >= tier_kingdom }
			min = 175
		}
		else = { min = 100 }
	}
	else = { min = 5 }
}

tribute_legitimacy_reward_value = minor_legitimacy_gain

tribute_generic_legitimacy_reward_value = {
	value = {
		add = tribute_legitimacy_reward_value
		multiply = 2
	}
}

create_bunga_mas_cost = 50

bunga_mas_tribute_modifier_cap = 3
