﻿regula_instiga_discordia = {

	# Basic Setup
	skill = diplomacy
	desc = regula_instiga_discordia_desc_general
	success_desc = "REGULA_INSTIGA_DISCORDIA_SUCCESS_DESC"
	discovery_desc = "REGULA_INSTIGA_DISCORDIA_DISCOVERY_DESC"
	icon = icon_scheme_regula
	illustration = "gfx/interface/illustrations/event_scenes/regula_alcove.dds"
	target_type = character
	is_secret = yes
	maximum_breaches = 5
	is_basic = yes
	is_secret = yes
	category = hostile

	# Parameters
	speed_per_skill_point = -10
	spymaster_speed_per_skill_point = 0	
	base_progress_goal = 180
	base_maximum_success = 95
	minimum_success = 5

	allow = {
		is_adult = yes
		is_imprisoned = no
		is_independent_ruler = no
	}

	valid = {
		# Is our target still around?
		scope:target = {
			is_alive = yes
			in_diplomatic_range = scope:owner	# Can travel (CK3 1.9) invalidate this?
		}
		# Is the Magister ok?
		magister_alive_trigger = yes
		# Is our target still the liege/spouse of our gossiper?
		scope:target = {
			OR = {
				target_is_liege_or_above = scope:owner
				target_is_vassal_or_below = scope:owner
				is_consort_of = scope:owner
			}
		}
	}

	odds_prediction = {
		add = base_odds_prediction_target_is_char_value
		add = odds_skill_contribution_diplomacy_value
		min = 5
	}

	base_success_chance = {
		base = 40

		hostile_scheme_base_chance_modifier = yes

		compare_modifier = {
			desc = "sway_my_diplomacy"
			target = scope:owner
			value = diplomacy
			multiplier = 5
		}
		# Proxy for trust
		opinion_modifier = {
			desc = SCHEME_BEFRIEND_THEIR_OPINION
			who = scope:target
			opinion_target = scope:owner
			max = 50
			min = -10
			multiplier = 0.75
		}
		# At War
		first_valid = {
			modifier = {
				add = -50
				desc = "SCHEME_AT_WAR"
				scope:target = {
					is_at_war = yes
				}
			}
		}
	}

	base_secrecy = {
		add = secrecy_base_value
		add = countermeasure_apply_secrecy_maluses_value
		min = 50
	}
	
	# On Actions
	on_phase_completed = {
		scheme_owner = {
			trigger_event = regula_instiga_discordia_outcome.0001
		}
	}

	on_invalidated = {
		scheme_target_character = {
			save_scope_as = target
		}
		scheme_owner = {
			save_scope_as = owner
		}

		# Our gossip target died
		if = {
			limit = {
				scope:target = { is_alive = no }
			}
			global_var:magister_character = {
				send_interface_toast = {
					title = regula_instiga_discordia_invalidated_title
					left_icon = scope:owner
					right_icon = scope:target
					custom_description_no_bullet = {
						object = scope:target
						text = scheme_target_died
					}
				}
			}
		}
	}
}