
# Values used by the Spymaster tasks and ongoing Scheme Discovery


monthly_scheme_discovery_chance_value = {
	# First grab our percentage chance to be discovered.
	value = 100
	subtract = scheme_secrecy
	# Then reduce it to 10% of itself, as it'll be checked very frequently.
	multiply = 0.1
}

spymaster_learn_on_the_job_scale = {
	value = 0
	if = {
		limit = {
			exists = liege
			liege = { has_perk = learn_on_the_job_perk }
		}
		add = intrigue
		multiply = {
			add = learn_on_the_job_percentage
			divide = 100
		}
		floor = yes
		min = 1
	}
}

### Reliable House modifier
spymaster_reliable_house_scale = {
	value = 0
	if = {
		limit = {
			exists = liege.dynasty
			liege.dynasty = { has_dynasty_perk = fp2_coterie_legacy_2 }
			house = liege.house
		}
		add = intrigue
		multiply = {
			add = council_reliable_house_percentage
			divide = 100
		}
		floor = yes
		min = 1
	}
}


#########################################
######## DISRUPT SCHEMES TASK ###########
#########################################

spymaster_disrupt_schemes_hostile_scheme_resistance_base = {
	add = 5
}

spymaster_disrupt_schemes_modifier_base_scale = {
	add = intrigue
	divide = 2
}

spymaster_disrupt_schemes_court_of_shadows_modifier_scale = {
	value = 0
	if = {
		limit = {
			exists = liege
			liege = { has_perk = court_of_shadows_perk }
		}
		add = {
			value = spymaster_disrupt_schemes_hostile_scheme_resistance_base
			add = spymaster_disrupt_schemes_modifier_base_scale
			multiply = {
				add = court_of_shadows_perk_percentage
				divide = 100
			}
		}
	}
}

spymaster_disrupt_schemes_erudition_legacy_5_modifier_scale = {
	value = 0
	if = {
		limit = {
			councillor_liege_has_erudition_legacy_5_perk = yes
		}
		add = {
			value = spymaster_disrupt_schemes_hostile_scheme_resistance_base
			add = spymaster_disrupt_schemes_modifier_base_scale
			multiply = {
				add = erudition_legacy_5_percentage
				divide = 100
			}
		}
	}
}

spymaster_disrupt_schemes_family_business_modifier_scale = {
	value = 0
	if = {
		limit = {
			councillor_liege_has_family_business_bonus = yes
		}
		add = {
			value = spymaster_disrupt_schemes_hostile_scheme_resistance_base
			add = spymaster_disrupt_schemes_modifier_base_scale
			multiply = {
				add = family_business_councillors_percentage
				divide = 100
			}
		}
	}
}

spymaster_disrupt_schemes_consulted_house_modifier_scale = {
	value = 0
	if = {
		limit = {
			councillor_liege_has_consulted_house_bonus = yes
		}
		add = {
			value = spymaster_disrupt_schemes_hostile_scheme_resistance_base
			add = spymaster_disrupt_schemes_modifier_base_scale
			multiply = {
				add = consulted_house_councillors_percentage
				divide = 100
			}
		}
	}
}

spymaster_disrupt_schemes_modifier_final_scale = {
	add = spymaster_disrupt_schemes_hostile_scheme_resistance_base
	add = spymaster_disrupt_schemes_modifier_base_scale
	add = spymaster_disrupt_schemes_court_of_shadows_modifier_scale
	add = spymaster_disrupt_schemes_erudition_legacy_5_modifier_scale
	add = spymaster_disrupt_schemes_family_business_modifier_scale
	add = spymaster_disrupt_schemes_consulted_house_modifier_scale
}

spymaster_disrupt_schemes_scheme_discovery_modifier = {
	add = intrigue
}

spymaster_find_secrets_disrupt_schemes_modifier = {
	add = intrigue
}

spymaster_find_secrets_disrupt_schemes_modifier_factor = {
	value = 100
	subtract = {
		value = spymaster_find_secrets_disrupt_schemes_modifier
		multiply = 3
	}
	min = 10
	divide = 100
}

spymaster_disrupt_schemes_court_of_shadows_scheme_discovery_modifier_scale = {
	value = 0
	if = {
		limit = {
			exists = liege
			liege = { has_perk = court_of_shadows_perk }
		}
		add = {
			add = spymaster_disrupt_schemes_scheme_discovery_modifier
			multiply = {
				add = court_of_shadows_perk_percentage
				divide = 100
			}
		}
	}
}

spymaster_disrupt_schemes_erudition_legacy_5_discovery_modifier_scale = {
	value = 0
	if = {
		limit = {
			councillor_liege_has_erudition_legacy_5_perk = yes
		}
		add = {
			add = spymaster_disrupt_schemes_scheme_discovery_modifier
			multiply = {
				add = erudition_legacy_5_percentage
				divide = 100
			}
		}
	}
}

spymaster_disrupt_schemes_family_business_discovery_modifier_scale = {
	value = 0
	if = {
		limit = {
			councillor_liege_has_family_business_bonus = yes
		}
		add = {
			add = spymaster_disrupt_schemes_scheme_discovery_modifier
			multiply = {
				add = family_business_councillors_percentage
				divide = 100
			}
		}
	}
}

spymaster_disrupt_schemes_consulted_house_discovery_modifier_scale = {
	value = 0
	if = {
		limit = {
			councillor_liege_has_consulted_house_bonus = yes
		}
		add = {
			add = spymaster_disrupt_schemes_scheme_discovery_modifier
			multiply = {
				add = consulted_house_councillors_percentage
				divide = 100
			}
		}
	}
}

spymaster_disrupt_schemes_total_modifier = {
	add = spymaster_disrupt_schemes_scheme_discovery_modifier
	add = spymaster_disrupt_schemes_court_of_shadows_scheme_discovery_modifier_scale
	add = spymaster_disrupt_schemes_erudition_legacy_5_discovery_modifier_scale
	add = spymaster_disrupt_schemes_family_business_discovery_modifier_scale
	add = spymaster_disrupt_schemes_consulted_house_discovery_modifier_scale
}


#########################################
######## ESPIONAGE SCHEME TASK ##########
#########################################

spymaster_espionage_modifier_base_scale = {
	add = intrigue
	multiply = -1
	max = -1
}

spymaster_espionage_legacy_bonus = {
	value = 0
	if = {
		limit = {
			councillor_liege_has_erudition_legacy_5_perk = yes
		}
		add = {
			value = spymaster_espionage_modifier_base_scale
			multiply = {
				value = erudition_legacy_5_percentage
				divide = 100
			}
		}
	}
}

spymaster_espionage_family_business_bonus = {
	value = 0
	if = {
		limit = {
			councillor_liege_has_family_business_bonus = yes
		}
		add = {
			value = spymaster_espionage_modifier_base_scale
			multiply = {
				value = family_business_councillors_percentage
				divide = 100
			}
		}
	}
}

spymaster_espionage_consulted_house_bonus = {
	value = 0
	if = {
		limit = {
			councillor_liege_has_consulted_house_bonus = yes
		}
		add = {
			value = spymaster_espionage_modifier_base_scale
			multiply = {
				value = consulted_house_councillors_percentage
				divide = 100
			}
		}
	}
}

spymaster_espionage_court_type_bonus = {
	value = 0
	if = {
		limit = {
			has_dlc_feature = royal_court
			scope:councillor_liege = {
				has_royal_court = yes
				has_dlc_feature = royal_court
				has_court_type = court_intrigue
				court_grandeur_current_level >= 4
			}
		}
		add = {
			value = spymaster_espionage_modifier_base_scale
			multiply = {
				value = court_intrigue_spymaster_task_bonus
				divide = 100
			}
		}
	}
}

spymaster_espionage_modifier_final_scale = {
	add = spymaster_espionage_modifier_base_scale
	add = spymaster_espionage_legacy_bonus
	add = spymaster_espionage_family_business_bonus
	add = spymaster_espionage_consulted_house_bonus
	add = spymaster_espionage_court_type_bonus
}

spymaster_espionage_success_chance_base = {
	add = 5
}

spymaster_espionage_success_chance_modifier_base_scale = {
	add = {
		add = intrigue
		multiply = 0.5
	}
}

spymaster_espionage_success_chance_legacy_bonus = {
	value = 0
	if = {
		limit = {
			councillor_liege_has_erudition_legacy_5_perk = yes
		}
		add = {
			value = spymaster_espionage_success_chance_base
			add = spymaster_espionage_success_chance_modifier_base_scale
			multiply = {
				value = erudition_legacy_5_percentage
				divide = 100
			}
		}
	}
}

spymaster_espionage_success_chance_family_business_bonus = {
	value = 0
	if = {
		limit = {
			councillor_liege_has_family_business_bonus = yes
		}
		add = {
			value = spymaster_espionage_success_chance_base
			add = spymaster_espionage_success_chance_modifier_base_scale
			multiply = {
				value = family_business_councillors_percentage
				divide = 100
			}
		}
	}
}

spymaster_espionage_success_chance_consulted_house_bonus = {
	value = 0
	if = {
		limit = {
			councillor_liege_has_consulted_house_bonus = yes
		}
		add = {
			value = spymaster_espionage_success_chance_base
			add = spymaster_espionage_success_chance_modifier_base_scale
			multiply = {
				value = consulted_house_councillors_percentage
				divide = 100
			}
		}
	}
}

spymaster_espionage_success_chance_court_type_bonus = {
	value = 0
	if = {
		limit = {
			has_dlc_feature = royal_court
			scope:councillor_liege = {
				has_royal_court = yes
				has_dlc_feature = royal_court
				has_court_type = court_intrigue
				court_grandeur_current_level >= 4
			}
		}
		add = {
			value = spymaster_espionage_success_chance_base
			add = spymaster_espionage_success_chance_modifier_base_scale
			multiply = {
				value = court_intrigue_spymaster_task_bonus
				divide = 100
			}
		}
	}
}

spymaster_espionage_success_chance_total = {
	add = spymaster_espionage_success_chance_base
	add = spymaster_espionage_success_chance_modifier_base_scale
	add = spymaster_espionage_success_chance_legacy_bonus
	add = spymaster_espionage_success_chance_family_business_bonus
	add = spymaster_espionage_consulted_house_bonus
	add = spymaster_espionage_success_chance_court_type_bonus
}

#########################################
########### FIND SECRET TASK ############
#########################################

spymaster_find_secrets_secret_discovery_chance = {
	add = scope:councillor.intrigue
	multiply = 5
	max = 95
}

spymaster_find_secrets_base = 5

spymaster_find_secrets_monthly_increase = {
	add = intrigue
}

spymaster_find_secrets_base_total = {
	add = spymaster_find_secrets_base
	add = spymaster_find_secrets_monthly_increase
}



# Relation impact
spymaster_find_secrets_monthly_increase_friend_bonus = {
	value = spymaster_find_secrets_base_total
	multiply = {
		add = council_friend_impact_percentage
		divide = 100
	}
}
spymaster_find_secrets_monthly_increase_best_friend_bonus = {
	value = spymaster_find_secrets_base_total
	multiply = {
		add = council_best_friend_impact_percentage
		divide = 100
	}
}
spymaster_find_secrets_monthly_increase_rival_bonus = {
	value = spymaster_find_secrets_base_total
	multiply = {
		add = council_rival_impact_percentage
		divide = 100
	}
}
spymaster_find_secrets_monthly_increase_nemesis_bonus = {
	value = spymaster_find_secrets_base_total
	multiply = {
		add = council_nemesis_impact_percentage
		divide = 100
	}
}

spymaster_find_secrets_perk_monthly_increase = {
	add = spymaster_find_secrets_base_total
	multiply = {
		add = digging_for_dirt_perk_percentage
		divide = 100
	}
}
spymaster_find_secrets_erudition_monthly_increase = {
	add = spymaster_find_secrets_base_total
	multiply = {
		add = erudition_legacy_5_percentage
		divide = 100
	}
}
spymaster_find_secrets_family_business_monthly_increase = {
	add = spymaster_find_secrets_base_total
	multiply = {
		add = family_business_councillors_percentage
		divide = 100
	}
}
spymaster_find_secrets_consulted_house_monthly_increase = {
	add = spymaster_find_secrets_base_total
	multiply = {
		add = consulted_house_councillors_percentage
		divide = 100
	}
}

spymaster_court_of_no_secrets_event_increase = {
	add = spymaster_find_secrets_base_total
	multiply = {
		add = 15
		divide = 100
	}
}
