﻿
#############################
# enemy_army_speed SCHEME
#############################
enemy_army_speed = {
	# Basic Setup
	skill = intrigue
	desc = enemy_army_speed_general_desc
	success_desc = "ENEMY_ARMY_SPEED_SUCCESS_DESC"
	icon = martial

	illustration = "gfx/interface/illustrations/event_scenes/corridor.dds"
	category = hostile
	target_type = character
	is_secret = yes
	is_basic = yes
	uses_resistance = yes
	maximum_breaches = 5
	cooldown = { years = 2 }
	
	# Parameters
	speed_per_skill_point = t1_spsp_owner_value
	spymaster_speed_per_skill_point = 0
	uses_resistance = yes
	base_progress_goal = t2_base_phase_length_value
	base_maximum_success = 95
	minimum_success = 5

	# Core Triggers
	allow = {
		is_adult = yes
		is_imprisoned = no
		is_at_war_with = scope:target
		scope:target = {
			is_adult = yes
			is_imprisoned = no
			is_ruler = yes
		}

		#AI blockers
		trigger_if = {
			limit = { is_ai = yes }

			scope:target = { #AI won't steal if they like you
				opinion = {
					target = scope:owner
					value <= 50
				}

				trigger_if = { #AI won't steal from friends... Unless...
					limit = {
						OR = {
							has_relation_friend = scope:owner 
							has_relation_best_friend = scope:owner 
						}
					}
					scope:owner = {
						OR = {
							has_trait = greedy
							has_trait = deceitful
						}
					}
				}
				trigger_if = { #So players don't get spammed by AIs trying to steal 
					limit = {
						is_ai = no
					}
					NOT = {
						any_targeting_scheme = {
							scheme_type = steal_back_artifact
						}
					}
				}
			}
		}
	}
	
	valid = {
		is_incapable = no
		is_at_war_with = scope:target
		scope:target = {
			OR = {
				exists = location
				in_diplomatic_range = scope:owner
			}
		}
	}
	odds_prediction = {
		add = base_odds_prediction_target_is_char_value
		add = odds_skill_contribution_intrigue_value
		add = odds_skill_contribution_martial_value
		min = 0
	}
	# Base Chances
	base_success_chance = {
		base = 0
		scheme_type_skill_success_chance_modifier = { SKILL = MARTIAL }
		scheme_type_skill_success_chance_modifier = { SKILL = INTRIGUE }
		scheme_type_skill_success_chance_modifier = { SKILL = INTRIGUE }
		#Distance modifier
		ttd_major_distance_modifier = yes
		# Countermeasures.
		apply_calculated_scheme_success_chance_adjustments_modifier = yes
		hostile_scheme_base_chance_modifier = yes
		
		#Intellect good
		modifier = {
			desc = "scheme_intellect_good_1"
			scope:owner = { has_trait = intellect_good_1 }
			add = 5
		}
		
		modifier = {
			desc = "scheme_intellect_good_2"
			scope:owner = { has_trait = intellect_good_2 }
			add = 10
		}
		
		modifier = {
			desc = "scheme_intellect_good_3"
			scope:owner = { has_trait = intellect_good_3 }
			add = 15
		}
		
		
		modifier = {
			desc = "scheme_education_martial_1"
			scope:owner = { has_trait = education_martial_1 }
			add = 5
		}
		modifier = {
			desc = "scheme_education_martial_2"
			scope:owner = { has_trait = education_martial_2 }
			add = 10
		}
		modifier = {
			desc = "scheme_education_martial_3"
			scope:owner = { has_trait = education_martial_3 }
			add = 15
		}
		modifier = {
			desc = "scheme_education_martial_4"
			scope:owner = { has_trait = education_martial_4 }
			add = 20
		}
		modifier = {
			desc = "scheme_education_martial_5"
			scope:owner = { has_trait = education_martial_5 }
			add = 25
		}

	}

	# On Actions
	on_phase_completed = {
		# Grab our scopes.
		save_scope_as = scheme
		scheme_target_character = { save_scope_as = target }
		scheme_owner = { save_scope_as = owner }
		enemy_army_speed_scheme_prep_effect = yes
	}
	on_invalidated = {
		scheme_target_character = {
			save_scope_as = target
		}
		scheme_owner = {
			save_scope_as = owner
		}
		if = {
			limit = {
				scope:target = { is_alive = no }
			}
			scope:owner = {
				send_interface_toast = {
					title = cki_scheme_invalidated_title
					custom_tooltip = cki_scheme_invalidated_dead
					left_icon = scope:target
				}
			}
		}
		if = {
			limit = {
				scope:target = { 
					NOT = { in_diplomatic_range = scope:owner } 
				}
			}
			scope:owner = {
				send_interface_toast = {
					title = cki_scheme_invalidated_title
					left_icon = scope:target
					custom_description_no_bullet = {
						object = scope:target
						text = scheme_target_not_in_diplomatic_range
					}
				}
			}
		}
	}
}
