#############
# Fury of the Northmen Scripted Values
#############

##################################################
# Decisions

defiant_high_monarch_conversion_boost_value = {
	value = 0
	add = court_chaplain_conversion_base_total
	multiply = 1.25
}

hold_gruesome_festival_decision_value = {
	value = 0
	if = {
		limit = { religion = religion:germanic_religion }
		# This actually probably *isn't* Biblical numerology creeping into accounts of pagan worship, since we have records of fighting in Sweden that was probably about this around every nine years or so between Christians and pagans.
		add = 9
	}
	else = { add = 10 }
}

gruesome_festival_prestige_cost_value = 200

gruesome_festival_key_sacrifice_piety_value = {
	value = 0
	# For a base, take the general stand of human sacrifice.
	if = {
		limit = { scope:activity.var:blot_sacrifice = flag:humans_regular }
		add = gruesome_festival_regular_human_piety_value
	}
	if = {
		limit = { scope:activity.var:blot_sacrifice = flag:humans_magnificent }
		add = gruesome_festival_magnificent_human_piety_value
	}
	# Landless faith hostility block.
	if = {
		limit = {
			scope:sacrifice = { is_landed_or_landless_administrative = no }
		}
		# HumSac'ing a hostile faith.
		if = {
			limit = {
				scope:gf_faith = {
					faith_hostility_level = {
						target = scope:sacrifice.faith
						value = faith_hostile_level
					}
					# Exempt faiths/families you syncretise with.
					NOR = {
						# Eastern Family syncretism.
						AND = {
							has_doctrine = tenet_eastern_syncretism
							scope:sacrifice.religion = { is_in_family = rf_eastern }
						}
						# Unreformed pagans syncretism.
						AND = {
							has_doctrine = tenet_unreformed_syncretism
							scope:sacrifice.faith = { has_doctrine_parameter = unreformed }
						}
						# Christian syncretism.
						AND = {
							has_doctrine = tenet_christian_syncretism
							scope:sacrifice.religion = religion:christianity_religion
						}
						# Islamic syncretism.
						AND = {
							has_doctrine = tenet_islamic_syncretism
							scope:sacrifice.religion = religion:islam_religion
						}
						# Jewish syncretism.
						AND = {
							has_doctrine = tenet_jewish_syncretism
							scope:sacrifice.religion = religion:judaism_religion
						}
					}
				}
			}
			add = minor_piety_gain
		}
		# HumSac'ing an evil faith.
		if = {
			limit = {
				scope:gf_faith = {
					faith_hostility_level = {
						target = scope:sacrifice.faith
						value = faith_evil_level
					}
				}
			}
			add = medium_piety_gain
		}
	}
	# Landed rank block.
	scope:sacrifice = {
		if = {
			limit = {
				is_landed_or_landless_administrative = yes
				# Exempt HoFs: they get their own block.
				NOT = { this = faith.religious_head }
			}
			# No extra gain for HumSac'ing a baron.
			# HumSac'ing a count.
			if = {
				limit = { highest_held_title_tier = tier_county }
				add = miniscule_piety_gain
			}
			# HumSac'ing a duke.
			if = {
				limit = { highest_held_title_tier = tier_duchy }
				add = minor_piety_gain
			}
			# HumSac'ing a king.
			if = {
				limit = { highest_held_title_tier = tier_kingdom }
				add = medium_piety_gain
			}
			# HumSac'ing an emperor.
			if = {
				limit = { highest_held_title_tier = tier_empire }
				add = major_piety_gain
			}
		}
	}
	# HoF block.
	## Weigh up HoFs that are not scope:gf_faith's own.
	if = {
		limit = {
			scope:sacrifice = {
				this = faith.religious_head
				NOT = { faith = scope:gf_faith }
			}
		}
		add = major_piety_gain
	}
	## Weigh up HoFs that *are* the HoF for scope:gf_faith.
	scope:sacrifice = {
		if = {
			limit = {
				this = faith.religious_head
				faith = scope:gf_faith
			}
			## HumSac'ing scope:gf_faith's own HoF, but they're sinful.
			if = {
				limit = { num_sinful_traits >= 2 }
				add = minor_piety_loss
			}
			## HumSac'ing scope:gf_faith's own HoF, and they're virtuous.
			else_if = {
				limit = { num_virtuous_traits >= 2 }
				add = major_piety_loss
			}			
			## HumSac'ing scope:gf_faith's own HoF, and they're neutral.
			else = { add = medium_piety_loss }
		}
	}
}

gruesome_festival_regular_animal_piety_value = {
	value = minor_piety_gain

	# If not of the faith, invert this & reduce it a little.
	if = {
		limit = {
			NOT = { faith = scope:gf_faith }
		}
		# HumSac faiths still aren't happy.
		if = {
			limit = {
				faith = {
					OR = {
						has_doctrine_parameter = flower_war_cb_active
						has_doctrine_parameter = human_sacrifice_active
						has_doctrine_parameter = gruesome_festivals_active
					}
				}
			}
			multiply = -0.25
		}
		# Non-HumSac faiths are horrified.
		else = { multiply = -0.75 }
	}
}

gruesome_festival_magnificent_animal_piety_value = {
	value = medium_piety_gain

	# If not of the faith, invert this & reduce it a little.
	if = {
		limit = {
			NOT = { faith = scope:gf_faith }
		}
		# HumSac faiths still aren't happy.
		if = {
			limit = {
				faith = {
					OR = {
						has_doctrine_parameter = flower_war_cb_active
						has_doctrine_parameter = human_sacrifice_active
						has_doctrine_parameter = gruesome_festivals_active
					}
				}
			}
			multiply = -0.25
		}
		# Non-HumSac faiths are horrified.
		else = { multiply = -0.75 }
	}
}

gruesome_festival_regular_human_piety_value = {
	value = medium_piety_gain

	# If not of the faith, invert this & reduce it a little.
	if = {
		limit = {
			NOT = { faith = scope:gf_faith }
		}
		# HumSac faiths still aren't happy.
		if = {
			limit = {
				faith = {
					OR = {
						has_doctrine_parameter = flower_war_cb_active
						has_doctrine_parameter = human_sacrifice_active
						has_doctrine_parameter = gruesome_festivals_active
					}
				}
			}
			multiply = -0.25
		}
		# Non-HumSac faiths are horrified.
		else = { multiply = -0.75 }
	}
}

gruesome_festival_magnificent_human_piety_value = {
	value = major_piety_gain

	# If not of the faith, invert this & reduce it a little.
	if = {
		limit = {
			NOT = { faith = scope:gf_faith }
		}
		# HumSac faiths still aren't happy.
		if = {
			limit = {
				faith = {
					OR = {
						has_doctrine_parameter = flower_war_cb_active
						has_doctrine_parameter = human_sacrifice_active
						has_doctrine_parameter = gruesome_festivals_active
					}
				}
			}
			multiply = -0.25
		}
		# Non-HumSac faiths are horrified.
		else = { multiply = -0.75 }
	}
}

gruesome_festival_gf_guests_rejecting_invite_list_max_value = {
	value = 0

	# Add +1 for every entity in the list.
	every_in_list = {
		variable = gf_guests_rejecting_invite_list
		add = 1
	}
	# Cap it out at the max for the event.
	max = 5
}

raise_stele_gold_cost = { value = medium_gold_value }

raise_stele_county_preference_cap_value = {
	value = 0

	# Add +1 for every entity in the list.
	every_in_list = {
		list = personally_held_counties_list
		add = 1
	}
	# Cap it out at the max for the event.
	max = 3
}

raise_stele_variant_ancestor_value = {
	value = 0

	# Weight up for stele-celebrating culture.
	if = {
		limit = { fp1_can_raise_stele_title_scope_trigger = yes }
		add = 25
	}
	# Weight up for low popular opinion.
	add = {
		value = this.county_opinion
		multiply = -1
	}
	# Weight down for existing stele.
	if = {
		limit = { exists = this.var:stele_slot_occupied }
		add = -100
	}
}

raise_stele_variant_conquest_value = {
	value = 0

	# Weight up for stele-celebrating culture.
	if = {
		limit = { fp1_can_raise_stele_title_scope_trigger = yes }
		add = 25
	}
	# Weight up for low control.
	add = {
		value = 100
		subtract = this.county_control
	}
	# Weight down for existing stele.
	if = {
		limit = { exists = this.var:stele_slot_occupied }
		add = -100
	}
}

raise_stele_variant_promotion_value = {
	value = 0

	# Weight up for stele-celebrating culture.
	if = {
		limit = { fp1_can_raise_stele_title_scope_trigger = yes }
		add = 25
	}
	# Weight up for development.
	add = this.development_level
	# Weight down for existing stele.
	if = {
		limit = { exists = this.var:stele_slot_occupied }
		add = -100
	}
}

fp1_stele_duration_value = {
	value = 50

	# Tone the power down for promotion stelae, as they're quite powerful.
	if = {
		limit = { scope:stele_type = flag:promotion }
		add = -30
	}
}

fp1_stele_desc_normal_weight_value = 1

fp1_stele_desc_upweight_weight_value = 5

fp1_stele_desc_heavy_upweight_weight_value = 50

fp1_stele_desc_always_upweight_weight_value = 10000


##################################################
# Adventurer System

scandinavian_adventurer_priority_value = {
	value = 0

	# Weight up preferred adventurers.
	if = {
		limit = { has_character_flag = prioritised_scandinavian_adventurer }
		add = 1000
	}
	#Add martial score directly
	add = martial
	#Add prowess score directly
	add = prowess
	#Add reduced diplomacy score
	add = {
		value = diplomacy
		multiply = 0.5
	}
	#Add reduced intrigue score
	add = {
		value = intrigue
		multiply = 0.5
	}
	#Weight up for prestige level
	add = {
		value = prestige_level
		multiply = 10
	}
	#+++Ambitious
	if = {
		limit = { has_trait = ambitious }
		add = 15
	}
	#+++Viking
	if = {
		limit = { has_trait = viking }
		add = 15
	}
	#++Strategist
	if = {
		limit = { has_trait = strategist }
		add = 10
	}
	#++Brave
	if = {
		limit = { has_trait = brave }
		add = 10
	}
	#++Stubborn
	if = {
		limit = { has_trait = stubborn }
		add = 10
	}
	#++Varangian
	if = {
		limit = { has_trait = varangian }
		add = 10
	}
	#+Any blademaster
	if = {
		limit = { has_trait = lifestyle_blademaster }
		add = 5
	}
	#+Diligent
	if = {
		limit = { has_trait = diligent }
		add = 5
	}
	#+Wrathful
	if = {
		limit = { has_trait = wrathful }
		add = 5
	}
	#+Impatient
	if = {
		limit = { has_trait = impatient }
		add = 5
	}
	#+Arrogant
	if = {
		limit = { has_trait = arrogant }
		add = 5
	}
	#+Vengeful
	if = {
		limit = { has_trait = vengeful }
		add = 5
	}
	#+Berserker
	if = {
		limit = { has_trait = berserker }
		add = 5
	}
	#+Shieldmaiden
	if = {
		limit = { has_trait = shieldmaiden }
		add = 5
	}
	#-Forgiving
	if = {
		limit = { has_trait = forgiving }
		add = -5
	}
	#-Humble
	if = {
		limit = { has_trait = humble }
		add = -5
	}
	#-Patient
	if = {
		limit = { has_trait = patient }
		add = -5
	}
	#-Calm
	if = {
		limit = { has_trait = calm }
		add = -5
	}
	#-Lazy
	if = {
		limit = { has_trait = lazy }
		add = -5
	}
	#--Craven
	if = {
		limit = { has_trait = craven }
		add = -10
	}
	#---Content
	if = {
		limit = { has_trait = content }
		add = -15
	}
	#Weight down heavily for pacifist faith.
	if = {
		limit = {
			faith = { has_doctrine_parameter = pacifist_opinion_active }
		}
		add = -30
	}
	#Weight up substantially if they have a (potential) relationship with a player.
	if = {
		limit = {
			OR = {
				any_relation = { type = soulmate this = { is_ai = no } }
				any_relation = { type = best_friend this = { is_ai = no } }
				any_relation = { type = nemesis this = { is_ai = no } }
			}
		}
		add = 300
	}
	else_if = {
		limit = {
			OR = {
				any_relation = { type = lover this = { is_ai = no } }
				any_relation = { type = friend this = { is_ai = no } }
				any_relation = { type = rival this = { is_ai = no } }
			}
		}
		add = 200
	}
	else_if = {
		limit = {
			OR = {
				any_relation = { type = potential_lover this = { is_ai = no } }
				any_relation = { type = potential_friend this = { is_ai = no } }
				any_relation = { type = potential_rival this = { is_ai = no } }
			}
		}
		add = 100
	}
}

scandinavian_adventurer_target_title_priority_value = {
	value = 0
	#Mark up larger sub-realms
	add = {
		value = 5
		multiply = holder.domain_size
	}
	#Mark up coastal counties.
	if = {
		limit = { is_coastal_county = yes }
		add = 10
	}
	#Mark up potential rivals & rivals.
	if = {
		limit = {
			holder = {
				any_relation = {
					type = potential_rival
					this = scope:scandi_adventurer
				}
			}
		}
		add = 25
	}
	if = {
		limit = {
			scope:scandi_adventurer = {
				any_relation = {
					type = rival
					this = scope:scandi_adventurer
				}
			}
		}
		add = 50
	}
	#Mark down potential friends & friends.
	if = {
		limit = {
			scope:scandi_adventurer = {
				any_relation = {
					type = potential_friend
					this = scope:scandi_adventurer
				}
			}
		}
		add = -25
	}
	if = {
		limit = {
			scope:scandi_adventurer = {
				any_relation = {
					type = friend
					this = scope:scandi_adventurer
				}
			}
		}
		add = -50
	}
	#Mark down potential lovers & lovers.
	if = {
		limit = {
			scope:scandi_adventurer = {
				any_relation = {
					type = potential_lover
					this = scope:scandi_adventurer
				}
			}
		}
		add = -25
	}
	if = {
		limit = {
			scope:scandi_adventurer = {
				any_relation = {
					type = lover
					this = scope:scandi_adventurer
				}
			}
		}
		add = -50
	}
	#Mark up Northern Germanic culture group counties.
	if = {
		limit = { culture = { has_cultural_pillar = heritage_north_germanic } }
		add = 20
	}
	#Mark up farmland, as it's good terrain.
	if = {
		limit = {
			title_province = { terrain = farmlands }
		}
		add = 15
	}
	#Mark up plains, as it's not bad terrain.
	if = {
		limit = {
			title_province = { terrain = plains }
		}
		add = 10
	}
	#Mark up wetlands, as it beats forests & taiga.
	if = {
		limit = {
			title_province = { terrain = wetlands}
		}
		add = 5
	}
	#Mark down hills, as there who wants to walk uphill?
	if = {
		limit = {
			title_province = { terrain = hills }
		}
		add = -5
	}
	#Non-tribal lands are desirable, since they're richer.
	if = {
		limit = {
			holder = {
				NOT = { government_has_flag = government_is_tribal }
			}
		}
		add = 10
	}
	#Mark down players a little more, since we don't want them to be constantly fending off pagans unless they've got the juciest lands around.
	if = {
		limit = {
			holder = { is_ai = no }
		}
		add = -20
	}
	#Mark down if holder has same faith.
	if = {
		limit = { holder.faith = scope:scandi_adventurer.faith }
		add = -20
	}
}

scandinavian_adventurer_fp1_0041_gold_value = { value = massive_gold_value }

scandinavian_adventurer_efficacy_loan_value = 500

##################################################
# Yearlies

fp1_funeral_longship_preferred_mourner_value = {
	value = 0

	# Weight up the player heir dramatically.
	if = {
		limit = {
			exists = root.player_heir
			this = root.player_heir
		}
		add = 100
	}
	# Soulmates get a boost.
	if = {
		limit = {
			any_relation = {
				type = soulmate
				this = root
			}
		}
		add = 75
	}
	# Best friends get a similar boost.
	if = {
		limit = {
			any_relation = {
				type = best_friend
				this = root
			}
		}
		add = 60
	}
	# Close family get a minor boost.
	if = {
		limit = { is_close_family_of = root }
		add = 25
	}

	# Players get a generic boost regardless.
	if = {
		limit = { is_ai = no }
		add = 50
	}
}

fp1_best_available_riddler_value = {
	value = 0

	# Wordy characters first and foremost.
	add = learning
	add = diplomacy
	# Weight up a little for wordsy trait-havers.
	if = {
		limit = { has_trait = journaller }
		add = 5
	}
	if = {
		limit = { has_trait = scholar }
		add = 5
	}
	if = {
		limit = { has_trait = theologian }
		add = 5
	}
	if = {
		limit = { has_trait = architect }
		add = 5
	}
}

fp1_0091_standard_ship_gold_cost = { value = major_gold_value }

fp1_0111_sorcerer_intrigue_high = very_high_skill_rating
fp1_0111_sorcerer_learning_high = very_high_skill_rating
fp1_0111_sorcerer_intrigue_low = mediocre_skill_rating
fp1_0111_sorcerer_learning_low = mediocre_skill_rating

##################################################
# Wars

varangian_adventurers_standard_levy_cap_value = 2000

varangian_adventurers_bonus_levies_value = {
	value = 0

	# Add troops for each appropriate county.
	every_sub_realm_county = {
		limit = {
			title_province = { geographical_region = dlc_fp1_region_core_mainland_scandinavia }
			culture = scope:attacker.culture
			faith = scope:attacker.faith
		}
		add = 1
	}

	max = {
		# Standard base max.
		value = varangian_adventurers_standard_levy_cap_value
	}
}

varangian_adventurer_cb_cost = {
	add = { value = 1000 desc = "CB_BASE_COST" }

	if = {
		limit = {
			scope:attacker = { has_variable = va_cb_tally }
		}
		multiply = scope:attacker.var:va_cb_tally
		desc = "PREVIOUS_VARANGIAN_ADVENTURES_COST"
	}

	# Reduce the cost to make this more feasible for the AI.
	scope:attacker = {
		if = {
			limit = { is_ai = yes }
			multiply = -0.75
		}
	}
}

varangian_adventures_bounty_amount_value = {
	# Base value for the minimum pot.
	value = 200

	# Add another 100g for non-tribals, since they're generally in harder spots.
	if = {
		limit = {
			scope:defender = {
				NOT = { government_has_flag = government_is_tribal }
			}
		}
		add = 100
	}
	# *Another* 100g per rank of scope:defender over ducal.
	if = {
		limit = {
			scope:defender = { highest_held_title_tier >= tier_kingdom }
		}
		add = 100
	}
	if = {
		limit = {
			scope:defender = { highest_held_title_tier >= tier_empire }
		}
		add = 100
	}
}

varangian_adventure_ai_targeting_value = {
	value = 100
	scope:attacker = {
		# Weight up independent dukes.
		if = {
			limit = {
				scope:defender = { highest_held_title_tier = tier_duchy}
			}
			add = 100
		}
		# Weight up for coastal counties.
		every_in_list = {
			list = target_titles
			limit = {
				tier = tier_county
				is_coastal_county = yes
			}
			add = 50
		}
		# Weight down independent religious heads.
		if = {
			limit = { scope:defender = scope:defender.faith.religious_head }
			add = -1000
		}
		# Weight down independent counts.
		if = {
			limit = {
				scope:defender = { highest_held_title_tier = tier_county }
			}
			add = -200
		}
		# Weight down small players.
		if = {
			limit = {
				scope:defender = {
					is_ai = no
					realm_size <= minor_realm_size
				}
			}
			add = -1000
		}
	}
}

##################################################
# Shieldmaidens

shieldmaiden_veterancy_cap = 20

##################################################
# Laws

authority_cooldown_breaker_value = {
	value = 0

	# Tribals get a slightly milder penalty, as their base cost is already high.
	if = {
		limit = { government_has_flag = government_is_tribal }
		add = 4
	}
	# Everyone else gets the standard multiplier.
	else = { add = 5 }
}

##################################################
# Trade Events

fp1_trade_events_eligible_settlement_value = {
	value = 0

	# Add fort level multiplied by 1000.
	if = {
		limit = {
			scope:barony.title_province = { fort_level = 1 }
		}
		add = 1000
	}
	if = {
		limit = {
			scope:barony.title_province = { fort_level = 2 }
		}
		add = 2000
	}
	if = {
		limit = {
			scope:barony.title_province = { fort_level = 3 }
		}
		add = 3000
	}
	if = {
		limit = {
			scope:barony.title_province = { fort_level = 4 }
		}
		add = 4000
	}
	if = {
		limit = {
			scope:barony.title_province = { fort_level = 5 }
		}
		add = 5000
	}
	if = {
		limit = {
			scope:barony.title_province = { fort_level = 6 }
		}
		add = 6000
	}
	if = {
		limit = {
			scope:barony.title_province = { fort_level = 7 }
		}
		add = 7000
	}
	if = {
		limit = {
			scope:barony.title_province = { fort_level = 8 }
		}
		add = 8000
	}
	if = {
		limit = {
			scope:barony.title_province = { fort_level = 9 }
		}
		add = 9000
	}
	if = {
		limit = {
			scope:barony.title_province = { fort_level >= 10 }
		}
		add = 10000
	}
	# Subtract 500 to give room for error.
	add = -500
}

fp1_trade_events_cash_settlement_value = {
	value = 0

	# Every point of development is worth 1g extra.
	add = scope:county.development_level

	# Keeping to a sensible minimum & a balanced maximum.
	min = 10
	max = 50
}

fp1_trade_events_truce_length_value = 3650

fp1_trade_events_truce_renewal_date_value = {
	value = fp1_trade_events_truce_length_value

	add = -30
}

##################################################
# Jomsvikings

fp1_jomsvikings_coup_priority_value = {
	value = 0

	# Weight up the Jomsvikings historical home, Walin.
	if = {
		limit = { this = title:c_kolobrzeg }
		add = 1000
	}
	# Weight up OCMs.
	if = {
		limit = {
			holder = {
				any_held_title = {
					tier = tier_county
					count = 1
				}
				NOT = {
					any_vassal = { highest_held_title_tier >= tier_county }
				}
			}
		}
		add = 100
	}
	# Weight up holders who have poor martial.
	add = {
		value = 50
		subtract = holder.martial
	}
	# Weight down larger realms.
	if = {
		limit = {
			holder = { realm_size >= minor_realm_size }
		}
		add = -20
	}
	if = {
		limit = {
			holder = { realm_size >= medium_realm_size }
		}
		add = -20
	}
	if = {
		limit = {
			holder = { realm_size >= major_realm_size }
		}
		add = -20
	}
	if = {
		limit = {
			holder = { realm_size >= massive_realm_size }
		}
		add = -20
	}
}

fp1_jomvsvikings_raid_value = {
	value = 0

	# Weight up for development.
	add = development_level
	# Weight up high control.
	add = county_control
	# Weight up for coastal counties.
	if = {
		limit = { is_coastal_county = yes }
		add = 50
	}
	# Weight down for fort level.
	if = {
		limit = {
			title_province = { fort_level >= 2 }
		}
		add = -25
	}
	if = {
		limit = {
			title_province = { fort_level >= 3 }
		}
		add = -25
	}
	if = {
		limit = {
			title_province = { fort_level >= 4 }
		}
		add = -25
	}
	if = {
		limit = {
			title_province = { fort_level >= 5 }
		}
		add = -25
	}
	if = {
		limit = {
			title_province = { fort_level >= 6 }
		}
		add = -25
	}
	# Weight down for capital.
	if = {
		limit = { this = root.capital_county }
		add = -200
	}
}

number_of_huscarls = {
	value = 50
	multiply = { 
		value = scope:recruiting_character.primary_title.tier
		add = -1
	}
}

number_of_bondi = {
	value = 100
	multiply = { 
		value = scope:recruiting_character.primary_title.tier
		add = -1
	}
}

huscarls_gold_value = {
	value = monthly_character_income
	multiply = 24
	min = 30
	max = 225

	#Rounds up to the closest number divisible by 5
	divide = 5
	ceiling = yes
	multiply = 5
}

bondi_gold_value = {
	value = monthly_character_income
	multiply = 12
	min = 15
	max = 125

	#Rounds up to the closest number divisible by 5
	divide = 5
	ceiling = yes
	multiply = 5
}
