﻿base_feast_cost_value = {
	add = {
		add = {
			value = feast_activity_cost
			desc = feast_activity_cost_desc
		}
		add = {
			value = feast_activity_cost
			multiply = activity_cost_scale_by_era
			subtract = feast_activity_cost
			desc = activity_cost_scale_by_era_desc
		}
		if = {
			limit = {
				scope:province ?= { has_building_or_higher = citadel_of_aleppo_01 }
			}
			add = {
				value = 0
				add = {
					value = feast_activity_cost
					add = {
						value = feast_activity_cost
						multiply = activity_cost_scale_by_era
						subtract = feast_activity_cost
					}
				}
				multiply = feast_activity_cost_discount_max_value
				desc = feast_cost_discount_citadel_of_aleppo
			}
		}
		if = {
			limit = {
				scope:province ?= { has_building_or_higher = palace_of_aachen_01 }
			}
			add = {
				value = 0
				add = {
					value = feast_activity_cost
					add = {
						value = feast_activity_cost
						multiply = activity_cost_scale_by_era
						subtract = feast_activity_cost
					}
				}
				multiply = feast_activity_cost_discount_max_value
				desc = feast_cost_discount_palace_of_aachen
			}
		}
		if = {
			limit = {
				scope:province ?= { has_building_or_higher = doges_palace_01 }
			}
			add = {
				value = 0
				add = {
					value = feast_activity_cost
					add = {
						value = feast_activity_cost
						multiply = activity_cost_scale_by_era
						subtract = feast_activity_cost
					}
				}
				multiply = feast_activity_cost_discount_max_value
				desc = feast_cost_discount_doges_palace
			}
		}
		if = {
			limit = {
				scope:host.domicile ?= {
					has_domicile_parameter = nomad_yurt_feast_discount
				}
			}
			add = {
				value = feast_activity_cost_discount_medium_value
				desc = feast_yurt_01_domicile_building
			}
		}
		if = {
			limit = {
				scope:province ?= { has_building_or_higher = ghana_palace_01 }
			}
			add = {
				value = 0
				add = {
					value = feast_activity_cost
					add = {
						value = feast_activity_cost
						multiply = activity_cost_scale_by_era
						subtract = feast_activity_cost
					}
				}
				multiply = feast_activity_cost_discount_max_value
				desc = feast_cost_discount_ghana_palace
			}
		}
		if = {
			limit = {
				scope:province ?= { has_building_or_higher = kyz_kala_01 }
			}
			add = {
				value = 0
				add = {
					value = feast_activity_cost
					add = {
						value = feast_activity_cost
						multiply = activity_cost_scale_by_era
						subtract = feast_activity_cost
					}
				}
				multiply = feast_activity_cost_discount_max_value
				desc = feast_cost_discount_kyz_kala
			}
		}
		if = {
			limit = {
				scope:province ?= { has_building_or_higher = leisure_palace_01 }
			}
			add = {
				value = 0
				add = {
					value = feast_activity_cost
					add = {
						value = feast_activity_cost
						multiply = activity_cost_scale_by_era
						subtract = feast_activity_cost
					}
				}
				multiply = feast_activity_cost_discount_max_value
				desc = feast_cost_discount_leisure_palaces
			}
		}
		if = {
			limit = {
				scope:province ?= { has_building_or_higher = alhambra_01 }
			}
			add = {
				value = 0
				add = {
					value = feast_activity_cost
					add = {
						value = feast_activity_cost
						multiply = activity_cost_scale_by_era
						subtract = feast_activity_cost
					}
				}
				multiply = feast_activity_cost_discount_max_value
				desc = feast_cost_discount_alhambra
			}
		}
		if = {
			limit = {
				scope:province ?= {
					has_building_or_higher = farm_estates_01
				}
			}
			add = {
				value = 0
				add = {
					value = feast_activity_cost
					add = {
						value = feast_activity_cost
						multiply = activity_cost_scale_by_era
						subtract = feast_activity_cost
					}
				}
				multiply = feast_activity_cost_discount_medium_value
				desc = feast_cost_discount_farm_estates
			}
		}
		if = {
			limit = {
				scope:province ?= {
					has_building_or_higher = paddy_fields_01
				}
			}
			add = {
				value = 0
				add = {
					value = feast_activity_cost
					add = {
						value = feast_activity_cost
						multiply = activity_cost_scale_by_era
						subtract = feast_activity_cost
					}
				}
				multiply = feast_activity_cost_discount_medium_value
				desc = feast_cost_discount_paddy_fields
			}
		}
		if = {
			limit = {
				scope:province ?= {	has_building_or_higher = longhouses_01 }
			}
			add = {
				value = 0
				add = {
					value = feast_activity_cost
					add = {
						value = feast_activity_cost
						multiply = activity_cost_scale_by_era
						subtract = feast_activity_cost
					}
				}
				multiply = feast_activity_cost_discount_medium_value
				desc = feast_cost_discount_longhouses
			}
		}
		if = {
			limit = {
				scope:province ?= {	has_building_or_higher = orchards_01 }
			}
			add = {
				value = 0
				add = {
					value = feast_activity_cost
					add = {
						value = feast_activity_cost
						multiply = activity_cost_scale_by_era
						subtract = feast_activity_cost
					}
				}
				multiply = feast_activity_cost_discount_min_value
				desc = feast_cost_discount_orchards
			}
		}
		if = {
			limit = {
				scope:province ?= {	has_building_or_higher = cereal_fields_01 }
			}
			add = {
				value = 0
				add = {
					value = feast_activity_cost
					add = {
						value = feast_activity_cost
						multiply = activity_cost_scale_by_era
						subtract = feast_activity_cost
					}
				}
				multiply = feast_activity_cost_discount_min_value
				desc = feast_cost_discount_cereal_fields
			}
		}
		if = {
			limit = {
				scope:province ?= {	has_building_or_higher = plantations_01	}
			}
			add = {
				value = 0
				add = {
					value = feast_activity_cost
					add = {
						value = feast_activity_cost
						multiply = activity_cost_scale_by_era
						subtract = feast_activity_cost
					}
				}
				multiply = feast_activity_cost_discount_min_value
				desc = feast_cost_discount_desert_agriculture
			}
		}
		if = {
			limit = {
				domicile ?= { has_domicile_parameter = estate_cheaper_feast_cost }
			}
			subtract = {
				value = 0
				add = {
					value = feast_activity_cost
					add = {
						value = feast_activity_cost
						multiply = activity_cost_scale_by_era
						subtract = feast_activity_cost
					}
				}
				multiply = estate_cheaper_feast_cost_value
				desc = estate_cheaper_feast_cost_desc
			}
		}
		if = {
			limit = {
				dynasty ?= {
					has_dynasty_perk = law_legacy_1
				}
			}
			subtract = {
				value = 0
				add = {
					value = feast_activity_cost
					add = {
						value = feast_activity_cost
						multiply = activity_cost_scale_by_era
						subtract = feast_activity_cost
					}
				}
				multiply = law_legacy_cost_reduction_mult
				desc = law_legacy_1_name
			}
		}
		#court.8140
		if = {
			limit = {
				has_character_flag = court_event_discount_feast
			}
			multiply = {
				value = 0.5
				desc = court_event_discount_desc
			}
		}
		#court.9100
		if = {
			limit = {
				has_character_modifier = promise_of_feasts_modifier
			}
			multiply = {
				value = 0.75
				desc = court_event_discount_desc
			}
		}
		#mpo_nerge.1060
		if = {
			limit = { has_variable = mpo_nerge_1060_free_feast }
			multiply = {
				value = 0 # Free
				desc = mpo_nerge_1060_free_feast_desc
			}
		}
		if = {
			limit = {
				has_character_modifier = more_work_less_fun_modifier
			}
			multiply = {
				value = 1.25
				desc = court_event_discount_desc
			}
		}
		if = {
			limit = {
				has_character_flag = food_improves_feasts
			}
			subtract = {
				value = 0
				add = {
					value = feast_activity_cost
					add = {
						value = feast_activity_cost
						multiply = activity_cost_scale_by_era
						subtract = feast_activity_cost
					}
				}
				multiply = 0.15
				desc = food_improves_feasts
			}
		}
		if = {
			limit = {
				has_character_modifier = journey_communal_modifier
			}
			multiply = {
				value = 0.8
				desc = journey_communal_modifier
			}
		}
		# Court Position
		if = {
			limit = {
				any_court_position_holder = {
					type = court_brewmaster_court_position
					aptitude = {
						court_position = court_brewmaster_court_position
						value >= 4
					}
				}
			}
			multiply = {
				value = 0.75
				desc = court_brewmaster_explanation
			}
		}
		else_if = {
			limit = {
				any_court_position_holder = {
					type = court_brewmaster_court_position
					aptitude = {
						court_position = court_brewmaster_court_position
						value >= 3
					}
				}
			}
			multiply = {
				value = 0.8
				desc = court_brewmaster_explanation
			}
		}
		else_if = {
			limit = {
				any_court_position_holder = {
					type = court_brewmaster_court_position
					aptitude = {
						court_position = court_brewmaster_court_position
						value >= 2
					}
				}
			}
			multiply = {
				value = 0.85
				desc = court_brewmaster_explanation
			}
		}
		else_if = {
			limit = {
				any_court_position_holder = {
					type = court_brewmaster_court_position
					aptitude = {
						court_position = court_brewmaster_court_position
						value >= 1
					}
				}
			}
			multiply = {
				value = 0.9
				desc = court_brewmaster_explanation
			}
		}
		else_if = {
			limit = {
				any_court_position_holder = {
					type = court_brewmaster_court_position
				}
			}
			multiply = {
				value = 0.95
				desc = court_brewmaster_explanation
			}
		}
		if = {
			limit = {
				has_character_modifier = mpo_si_slaughtered_animals
			}
			multiply = {
				value = 0.5
				desc = mpo_si_slaughtered_animals
			}
		}
		if = {
			limit = {
				has_character_modifier = mpo_nerge_feast_discount
			}
			multiply = {
				value = 0.5
				desc = mpo_nerge_feast_discount
			}
		}
		if = {
			limit = {
				house ?= { has_house_power_parameter = ceremony_cheaper_feasts }
			}
			multiply = {
				value = 0.75
				desc = ceremony_cheaper_feasts
			}
		}
		if = {
			limit = {
				government_has_flag = government_is_japan_administrative
			}
			multiply = {
				value = 0.75
				desc = japan_administrative_government
			}
		}
		if = {
			limit = {
				confederation ?= { has_cohesion_level_parameter = any_member_activity_cost_reduced }
			}
			multiply = {
				value = 0.9
				desc = CB_COHESION_PARAMETER_DISCOUNT
			}
		}
		if = {
			limit = {
				var:tgp_ceremonial_liege_events_0020_discount ?= flag:feast
			}
			multiply = {
				value = 0.85
				desc = tgp_ceremonial_liege_events_0020_discount_desc
			}
		}
		#RWE
		if = {
			limit = { has_character_flag = had_court_wedding }
			multiply = 0.50
			desc = court_wedding_feast_discount
		}
		if = {
			limit = { has_character_flag = had_court_wedding_wait }
			multiply = 0.80
			desc = court_wedding_feast_discount
		}
		#/RWE
		min = 0
	}
}

base_feast_ui_cost_value = {
	add = { # Base Cost, scaled by era
		value = feast_activity_cost
		multiply = activity_cost_scale_by_era
	}

	# Options
	add = { # Food
		value = 0 # Bad Option Cost
		add = 10 # Normal Option Cost
		add = 35 # Good Option Cost
		# Scale the sum of the options by era and tier
		add = {
			value = 45
			multiply = activity_cost_scale_by_tier
		}
		add = {
			value = 45
			multiply = activity_cost_scale_by_era
		}
		# Divide by 3 (num of levels for this option) so we get the average option cost
		divide = 3
	}
	add = { # Courses
		value = 0 # Bad Option Cost
		add = 10 # Normal Option Cost
		add = 35 # Good Option Cost
		# Scale the sum of the options by era and tier
		add = {
			value = 45
			multiply = activity_cost_scale_by_tier
		}
		add = {
			value = 45
			multiply = activity_cost_scale_by_era
		}
		# Divide by 3 (num of levels for this option) so we get the average option cost
		divide = 3
	}
	save_temporary_value_as = pre_discount_feast_cost_ui
	if = {
		limit = {
			dynasty ?= {
				has_dynasty_perk = law_legacy_1
			}
		}
		subtract = {
			value = scope:pre_discount_feast_cost_ui
			multiply = law_legacy_cost_reduction_mult
		}
	}
	#court.8140
	if = {
		limit = {
			has_character_flag = court_event_discount_feast
		}
		multiply = {
			value = 0.5
		}
	}

	if = {
		limit = {
			house ?= { has_house_power_parameter = ceremony_cheaper_feasts }
		}
		multiply = {
			value = 0.75
			desc = ceremony_cheaper_feasts
		}
	}
	if = {
		limit = {
			confederation ?= { has_cohesion_level_parameter = any_member_activity_cost_reduced }
		}
		multiply = {
			value = 0.9
			desc = CB_COHESION_PARAMETER_DISCOUNT
		}
	}
	if = {
		limit = {
			var:tgp_ceremonial_liege_events_0020_discount ?= flag:feast
		}
		multiply = {
			value = 0.85
			desc = tgp_ceremonial_liege_events_0020_discount_desc
		}
	}
	#RWE
	if = {
		limit = { has_character_flag = had_court_wedding }
		multiply = 0.50
		desc = court_wedding_feast_discount
	}
	if = {
		limit = { has_character_flag = had_court_wedding_wait }
		multiply = 0.80
		desc = court_wedding_feast_discount
	}
	#/RWE

	# Make it a multiple of 5 (rounded up)
	round_to = 5
}

feast_type_murder_value = {
	add = {
		add = {
			value = feast_activity_cost
			multiply = 2.5
			desc = murder_feast_activity_cost_desc
		}
		add = {
			value = feast_activity_cost
			multiply = 2.5
			multiply = activity_cost_scale_by_era
			subtract = {
				value = feast_activity_cost
				multiply = 2.5
			}
			desc = activity_cost_scale_by_era_desc
		}
	}
	if = {
		limit = {
			dynasty ?= {
				has_dynasty_perk = law_legacy_1
			}
		}
		subtract = {
			value = feast_activity_cost
			multiply = 2.5
			multiply = activity_cost_scale_by_era
			multiply = law_legacy_cost_reduction_mult
			desc = law_legacy_1_name
		}
	}
	if = {
		limit = {
			has_character_modifier = mpo_si_slaughtered_animals
		}
		multiply = {
			value = 0.5
			desc = mpo_si_slaughtered_animals
		}
	}
	if = {
		limit = {
			has_character_modifier = mpo_nerge_feast_discount
		}
		multiply = {
			value = 0.5
			desc = mpo_nerge_feast_discount
		}
	}
	#RWE
	if = {
		limit = {
			has_character_flag = had_court_wedding
		}
		desc = court_wedding_feast_discount
		multiply = 1.50
	}
	if = {
		limit = {
			has_character_flag = had_court_wedding_wait
		}
		multiply = 1.25
		desc = court_wedding_feast_discount
	}
	#/RWE
	if = {
		limit = {
			is_ai = yes
			has_character_flag = feast_ai_override
		}
		multiply = 0
	}
}

feast_food_normal_value = {
	add = {
		desc = feast_food_normal
		add = {
			value = 10
			desc = feast_food_normal
		}
		add = {
			value = 10
			multiply = activity_cost_scale_by_tier
			subtract = 10
			desc = activity_cost_scale_by_tier_desc
		}
		add = {
			value = 10
			multiply = activity_cost_scale_by_era
			subtract = 10
			desc = activity_cost_scale_by_era_desc
		}
		if = {
			limit = {
				dynasty ?= {
					has_dynasty_perk = law_legacy_1
				}
			}
			subtract = {
				value = 10
				add = {
					value = 10
					multiply = activity_cost_scale_by_tier
					subtract = 10
				}
				add = {
					value = 10
					multiply = activity_cost_scale_by_era
					subtract = 10
				}
				multiply = law_legacy_cost_reduction_mult
				desc = law_legacy_1_name
			}
		}
		if = {
			limit = {
				has_perk = journey_planner_perk
			}
			multiply = {
				value = voyager_journey_planner_value
				desc = journey_planner_perk_name
			}
		}
		if = {
			limit = {
				has_character_modifier = mpo_si_slaughtered_animals
			}
			multiply = {
				value = 0.5
				desc = mpo_si_slaughtered_animals
			}
		}
		if = {
			limit = {
				has_character_modifier = mpo_nerge_feast_discount
			}
			multiply = {
				value = 0.5
				desc = mpo_nerge_feast_discount
			}
		}
		#RWE
			if = {
				limit = { has_character_flag = had_court_wedding }
				multiply = 0.75
			}
			if = {
				limit = { has_character_flag = had_court_wedding_wait }
				multiply = 0.90
				desc = court_wedding_feast_discount
			}
		#/RWE
		min = 0
	}
}

feast_food_good_value = {
	add = {
		desc = feast_food_good
		add = {
			value = 35
			desc = feast_food_good
		}
		add = {
			value = 35
			multiply = activity_cost_scale_by_tier
			subtract = 35
			desc = activity_cost_scale_by_tier_desc
		}
		add = {
			value = 35
			multiply = activity_cost_scale_by_era
			subtract = 35
			desc = activity_cost_scale_by_era_desc
		}
		if = {
			limit = {
				dynasty ?= {
					has_dynasty_perk = law_legacy_1
				}
			}
			subtract = {
				value = 35
				add = {
					value = 35
					multiply = activity_cost_scale_by_tier
					subtract = 35
				}
				add = {
					value = 35
					multiply = activity_cost_scale_by_era
					subtract = 35
				}
				multiply = law_legacy_cost_reduction_mult
				desc = law_legacy_1_name
			}
		}
		if = {
			limit = {
				has_perk = journey_planner_perk
			}
			multiply = {
				value = voyager_journey_planner_value
				desc = journey_planner_perk_name
			}
		}
		if = {
			limit = {
				has_character_modifier = mpo_si_slaughtered_animals
			}
			multiply = {
				value = 0.5
				desc = mpo_si_slaughtered_animals
			}
		}
		if = {
			limit = {
				has_character_modifier = mpo_nerge_feast_discount
			}
			multiply = {
				value = 0.5
				desc = mpo_nerge_feast_discount
			}
		}
		#Mandala Godking AI
		if = {
			limit = { 
				has_variable = mandala_godking
				is_ai = yes
			}
			multiply = 0.25
		}
		#RWE
		if = {
			limit = { has_character_flag = had_court_wedding }
			multiply = 0.75
		}
		if = {
			limit = { has_character_flag = had_court_wedding_wait }
			multiply = 0.90
			desc = court_wedding_feast_discount
			}
		#/RWE
		min = 0
	}
}

feast_courses_normal_value = {
	add = {
		desc = feast_courses_normal
		add = {
			value = 10
			desc = feast_courses_normal
		}
		add = {
			value = 10
			multiply = activity_cost_scale_by_tier
			subtract = 10
			desc = activity_cost_scale_by_tier_desc
		}
		add = {
			value = 10
			multiply = activity_cost_scale_by_era
			subtract = 10
			desc = activity_cost_scale_by_era_desc
		}
		if = {
			limit = {
				dynasty ?= {
					has_dynasty_perk = law_legacy_1
				}
			}
			subtract = {
				value = 10
				add = {
					value = 10
					multiply = activity_cost_scale_by_tier
					subtract = 10
				}
				add = {
					value = 10
					multiply = activity_cost_scale_by_era
					subtract = 10
				}
				multiply = law_legacy_cost_reduction_mult
				desc = law_legacy_1_name
			}
		}
		if = {
			limit = {
				has_perk = journey_planner_perk
			}
			multiply = {
				value = voyager_journey_planner_value
				desc = journey_planner_perk_name
			}
		}
		if = {
			limit = {
				has_character_modifier = mpo_si_slaughtered_animals
			}
			multiply = {
				value = 0.5
				desc = mpo_si_slaughtered_animals
			}
		}
		if = {
			limit = {
				has_character_modifier = mpo_nerge_feast_discount
			}
			multiply = {
				value = 0.5
				desc = mpo_nerge_feast_discount
			}
		}
		#RWE
		if = {
			limit = { has_character_flag = had_court_wedding }
			multiply = 0.75
		}
		if = {
			limit = { has_character_flag = had_court_wedding_wait }
			multiply = 0.90
			desc = court_wedding_feast_discount
			}
		#/RWE
		min = 0
	}
}

feast_courses_good_value = {
	add = {
		desc = feast_courses_good
		add = {
			value = 35
			desc = feast_courses_good
		}
		add = {
			value = 35
			multiply = activity_cost_scale_by_tier
			subtract = 35
			desc = activity_cost_scale_by_tier_desc
		}
		add = {
			value = 35
			multiply = activity_cost_scale_by_era
			subtract = 35
			desc = activity_cost_scale_by_era_desc
		}
		if = {
			limit = {
				dynasty ?= {
					has_dynasty_perk = law_legacy_1
				}
			}
			subtract = {
				value = 35
				add = {
					value = 35
					multiply = activity_cost_scale_by_tier
					subtract = 35
				}
				add = {
					value = 35
					multiply = activity_cost_scale_by_era
					subtract = 35
				}
				multiply = law_legacy_cost_reduction_mult
				desc = law_legacy_1_name
			}
		}
		if = {
			limit = {
				has_perk = journey_planner_perk
			}
			multiply = {
				value = voyager_journey_planner_value
				desc = journey_planner_perk_name
			}
		}
		if = {
			limit = {
				has_character_modifier = mpo_si_slaughtered_animals
			}
			multiply = {
				value = 0.5
				desc = mpo_si_slaughtered_animals
			}
		}
		if = {
			limit = {
				has_character_modifier = mpo_nerge_feast_discount
			}
			multiply = {
				value = 0.5
				desc = mpo_nerge_feast_discount
			}
		}
		#RWE
		if = {
			limit = { has_character_flag = had_court_wedding }
			multiply = 0.75
		}
		if = {
			limit = { has_character_flag = had_court_wedding_wait }
			multiply = 0.90
			desc = court_wedding_feast_discount
			}
		#/RWE
		min = 0
	}
}
