﻿########################
# Scheme Script Values #
########################

# Here we add bonus start progress based on the "closeness" of the target
# It probally wound't take a year to Fascinare your wife who you sleep with ^_^

# We'll start with opinion, then add bonuses/maluses
# then divide by 10 to get bonus progress

# Factors to consider are
# - Opinion status
# - Relationship (marriage/family/friend/rival)
# - Distance to them (in your court/vassal court/foreign court)
# - Intimidation status
# TODO: add more?

# scope:scheme = Fascinare Scheme
# scope:owner = Fascinare Schemer
# scope:target = Fascinare Target
fascinare_start_progress = {
	value = scope:scheme.scheme_phase_duration

	# Opinion check
	add = "scope:target.opinion(scope:owner)"

	# Divide it by 5 as well
	divide = 5

	# Same Religion?
	if = {
		limit = {
			scope:target = {has_religion = scope:owner.religion}
		}
		add = 30
	}
	else = {
		subtract = 10
	}

	# Same Culture?
	if = {
		limit = {
			scope:target = {has_culture = scope:owner.culture}
		}
		add = 10
	}


	# Check relationship status
	# Family
	if = {
		limit = {
			scope:target = {is_consort_of = scope:owner}
		}
		add = 30
	}
	if = {
		limit = {
			scope:target = {is_close_family_of = scope:owner}
		}
		add = 20
	}
	if = {
		limit = {
			OR = {
				scope:target = {is_extended_family_of = scope:owner}
				scope:target.dynasty = scope:owner.dynasty
			}
		}
		add = 10
	}

	# Special friend/rival/lover status
	if = {
		limit = {
			scope:target = {has_relation_lover = scope:owner}
		}
		add = 50
	}
	if = {	# bruh
		limit = {
			scope:target = {has_relation_soulmate = scope:owner}
		}
		add = 100
	}


	if = {
		limit = {
			scope:target = {has_relation_friend = scope:owner}
		}
		add = 10
	}
	if = {
		limit = {
			scope:target = {has_relation_best_friend = scope:owner}
		}
		add = 20
	}

	if = {
		limit = {
			scope:target = {has_relation_nemesis = scope:owner}
		}
		subtract = 30
	}
	if = {
		limit = {
			scope:target = {has_relation_nemesis = scope:owner}
		}
		subtract = 50
	}

	# Check Distance
	if = { # These are people in our court/nearby
		limit = {
			scope:target = {
				OR = {
					is_at_same_location = scope:owner
					is_vassal_or_below_of = scope:owner
					is_courtier_of = scope:owner
					is_foreign_court_guest_of = scope:owner
					is_pool_guest_of = scope:owner
				}
			}
		}
		add = 20
	}
	else = { # Otherwise they are in a foreign court, gives a malus
		subtract = 20
	}

	# Check Intimidation
	if = {
		limit = {
			scope:target = {
				has_dread_level_towards ={
					target = scope:owner
					level = 2
				}
			}
		}
		add = 20
	}
	if = {
		limit = {
			scope:target = {
				has_dread_level_towards ={
					target = scope:owner
					level = 1
				}
			}
		}
		add = 10
	}

	# If we have legacy perk add to extra progress
	if = {
		limit = {
			scope:owner.dynasty = { regula_legacy_track_perks >= 1 }
		}
		add = 30
	}

	# Add scheme progress based on fascinare_bonus
	# Make sure we aren't out of range by clamping
	max = {
		value = scope:scheme.scheme_phase_duration
		subtract = 10
	}
	min = 0

	# If we have legacy perk clamp to extra progress
	# this ensures we always have at least 3+ progress when starting a charm scheme
	if = {
		limit = {
			scope:owner.dynasty = { regula_legacy_track_perks >= 1 }
		}
		max = {
			value = scope:scheme.scheme_phase_duration
			subtract = 10
		}
		min = 30
	}
}