# Vanilla operation IDs kept for compatibility with vanilla AI strategies and operative traits.


operation_boost_resistance = { ### 8 2/40
	icon = GFX_operations_boost_resistance
	map_icon = GFX_operations_boost_resistance_map
	name = operation_boost_resistance
	desc = operation_boost_resistance_desc
	priority = 8
	
	cost_multiplier = 0.25
	
	days = 50
	network_strength = 35
	operatives = 2

	visible = {
		network_national_coverage = {
			target = FROM
			value > 0
		}

		has_operation_token = {
			tag = FROM
			token = token_resistance_contacts
		}
	}

	selection_target = {
		targets = { FROM }
	}

	selection_target_state = {
		has_resistance = yes
	}

	equipment = {

	}

	required_tokens = {
		token_resistance_contacts
	}
	risk_chance = 0.2
	experience = 1.5
	outcome_extra_chance = 0.25
	outcome_modifiers = { boost_resistance_factor }
	outcome_execute = {
		FROM.FROM = {
			if = {
				limit = {
					ROOT = {
						has_completed_focus = SWI_export_saboteurs
					}
				}
				add_resistance_target = {
					amount = 25
					tooltip = intelligency_agency_resistance_boost_tt
				}
				add_compliance = -15
			}
			else = {
				add_resistance_target = {
					amount = 10
					tooltip = intelligency_agency_resistance_boost_tt
				}
			}
			subtract_from_variable = { boost_resistance_chance = 10 }
		}
	}
	outcome_extra_execute = { # SCOPE_OPERATION
		random_list = {
			33 = { #critical success
				FROM.FROM = {
					add_resistance_target = {
						amount = 20
						tooltip = intelligency_agency_resistance_boost_tt
					}
					subtract_from_variable = { boost_resistance_chance = 10 }
				}
				FROM.FROM = {
					add_compliance = -10
				}
			}
			67 = { #normal success
				FROM.FROM = {
					add_resistance_target = {
						amount = 20
						tooltip = intelligency_agency_resistance_boost_tt
					}
					subtract_from_variable = { boost_resistance_chance = 10 }
				}
			}
		}
	}

	outcome_potential = {
		FROM.FROM = {
			if = {
				limit = {
					ROOT = {
						has_completed_focus = SWI_export_saboteurs
					}
				}
				add_resistance_target = {
					amount = 25
					tooltip = intelligency_agency_resistance_boost_tt
				}
				add_compliance = -15
			}
			else = {
				add_resistance_target = {
					amount = 10
					tooltip = intelligency_agency_resistance_boost_tt
				}
			}
		}
	}

	
	target_weight = {
		base = 100
		
		modifier = {
			add = boost_resistance_chance
		}
		
		modifier = {
			set_temp_variable = { t = distance_to@ROOT.capital }
			divide_temp_variable = { t = 600 }
			clamp_temp_variable = { var = t min = 0 max = 1 }
			multiply_temp_variable = { t = -40 }
			
			add = t
		}
	}
	
	phases = { #infiltration
		infiltration_border = { base = 50 }
		infiltration_submarine = { base = 25 }
		infiltration_paradrop = { 
			base = 25 
		}
	}
	phases = { #resistance support
		resistance_support_arms_depots = { base = 25 }
		resistance_support_distribute_weapons = { base = 25 }
		resistance_support_organize_training = { base = 25 }
		resistance_support_coordinate_groups = { base = 25 }
	}
	phases = { #exfiltration
		exfiltration_air_pickup = { 
			base = 15 
		}
		exfiltration_border = { base = 30 }
		exfiltration_go_to_ground = { base = 30 }
		exfiltration_submarine_pickup = { base = 25 }
	}
}


operation_targeted_sabotage_industry = { ### 13 3/35
	icon = GFX_operations_targeted_sabotage
	map_icon = GFX_operations_targeted_sabotage_map
	name = operation_targeted_sabotage_industry
	desc = operation_targeted_sabotage_industry_desc
	priority = 13
	
	days = 90
	network_strength = 35
	operatives = 3

	visible = {
		num_of_operatives > 1
		network_national_coverage = {
			target = FROM
			value > 0
		}


		has_operation_token = {
			tag = FROM
			token = token_resistance_contacts
		}
	}

	requirements = {
		FROM = {
			any_controlled_state = {
				has_resistance = yes
			}
		}
	}
	selection_target = {
		targets = { FROM }
	}

	selection_target_state = {
		has_resistance = yes
	}
	required_tokens = { token_resistance_contacts }
	equipment = {
		
	}

	risk_chance = 0.2
	experience = 2
	outcome_extra_chance = 0.25
	outcome_modifiers = { target_sabotage_factor operation_risk }
	risk_modifiers = { target_sabotage_risk operation_outcome }
	cost_modifiers = { target_sabotage_cost operation_cost }
	outcome_execute = {
		FROM.FROM = {
			add_to_variable = {
				var = targeted_sabotage_industry
				value = 5
			}
			custom_effect_tooltip = targeted_sabotage_industry_2_tt
		}
		ROOT = {
			remove_operation_token = {
				tag = FROM
				token = token_resistance_contacts
			}
		}
	}
	outcome_extra_execute = { # SCOPE_OPERATION
		
		FROM.FROM = {
			add_to_variable = {
				var = targeted_sabotage_industry
				value = 8
			}
			custom_effect_tooltip = targeted_sabotage_industry_3_tt
		}		
	}

	outcome_potential = {
		custom_effect_tooltip = operation_outcome_sabotage_industry_tt
		custom_effect_tooltip = operation_outcome_consumes_token_tt
	}

	phases = { #infiltration
		infiltration_border = { base = 25 }
		infiltration_submarine = { base = 25 }
		infiltration_paradrop = { 
			base = 25 
			modifier = {
				ROOT = { 
					has_equipment = {
						transport_plane_equipment < 1
					}
				}
				factor = 0
			}
		}
		infiltration_diplomatic = {
			base = 25
			modifier = {
				factor = 20
				ROOT = { has_war = no }
				FROM = {
					has_war = no
				}
			}
			modifier = {
				FROM = {
					has_war_with = ROOT
				}
				factor = 0
			}
		}
	}
	phases = { #exfiltration
		targeted_sabotage_plant_explosives = { base = 90 }
		targeted_sabotage_organize_more_meetings = { base = 10 }
	}
	phases = { #exfiltration
		exfiltration_air_pickup = { 
			base = 15 
			modifier = {
				ROOT = { 
					has_equipment = {
						transport_plane_equipment < 1
					}
				}
				factor = 0
			}
		}
		exfiltration_border = { base = 30 }
		exfiltration_go_to_ground = { base = 30 }
		exfiltration_submarine_pickup = { base = 25 }
	}
}


operation_targeted_sabotage_infrastructure = { ### 14 3/35
	icon = GFX_operations_targeted_sabotage
	map_icon = GFX_operations_targeted_sabotage_map
	name = operation_targeted_sabotage_infrastructure
	desc = operation_targeted_sabotage_infrastructure_desc
	priority = 14
	
	days = 90
	network_strength = 35
	operatives = 3

	visible = {
		num_of_operatives > 1
		network_national_coverage = {
			target = FROM
			value > 0
		}

		has_operation_token = {
			tag = FROM
			token = token_resistance_contacts
		}
	}	

	requirements = {
		FROM = {
			any_controlled_state = {
				has_resistance = yes
			}
		}
	}
	selection_target_state = {
		has_resistance = yes
	}
	selection_target = {
		targets = { FROM }
	}
	required_tokens = { token_resistance_contacts }
	equipment = {
		
	}
	risk_chance = 0.2
	experience = 2
	outcome_extra_chance = 0.25
	outcome_modifiers = { target_sabotage_factor operation_risk }
	risk_modifiers = { target_sabotage_risk operation_outcome }
	cost_modifiers = { target_sabotage_cost operation_cost }
	
	outcome_execute = {
		FROM.FROM = {
			add_to_variable = {
				var = targeted_sabotage_infrastructure
				value = 5
			}
			custom_effect_tooltip = targeted_sabotage_infrastructure_2_tt
		}
		ROOT = {
			remove_operation_token = {
				tag = FROM
				token = token_resistance_contacts
			}
		}
	}
	outcome_extra_execute = { # SCOPE_OPERATION
		FROM.FROM = {
			add_to_variable = {
				var = targeted_sabotage_infrastructure
				value = 8
			}
			custom_effect_tooltip = targeted_sabotage_infrastructure_3_tt
		}
	}
	outcome_potential = {
		custom_effect_tooltip = operation_outcome_sabotage_infrastructure_tt
		custom_effect_tooltip = operation_outcome_consumes_token_tt
	}
	phases = { #infiltration
		infiltration_border = { base = 25 }
		infiltration_submarine = { base = 25 }
		infiltration_paradrop = { 
			base = 25 
			modifier = {
				ROOT = { 
					has_equipment = {
						transport_plane_equipment < 1
					}
				}
				factor = 0
			}
		}
		infiltration_diplomatic = {
			base = 25
			modifier = {
				factor = 20
				ROOT = { has_war = no }
				FROM = {
					has_war = no
				}
			}
			modifier = {
				FROM = {
					has_war_with = ROOT
				}
				factor = 0
			}
		}
	}
	phases = {
		targeted_sabotage_destroy_bridge = { base = 25 }
		targeted_sabotage_collapse_tunnel = { base = 25 }
		targeted_sabotage_remove_roadsigns = { base = 25 }
		targeted_sabotage_immobilize_rolling_stock = { base = 25 }
	}
	phases = { #exfiltration
		exfiltration_air_pickup = { 
			base = 15 
			modifier = {
				ROOT = { 
					has_equipment = {
						transport_plane_equipment < 1
					}
				}
				factor = 0
			}
		}
		exfiltration_border = { base = 30 }
		exfiltration_go_to_ground = { base = 30 }
		exfiltration_submarine_pickup = { base = 25 }
	}
}


operation_targeted_sabotage_resources = { ### 15 3/35
	icon = GFX_operations_targeted_sabotage
	map_icon = GFX_operations_targeted_sabotage_map
	name = operation_targeted_sabotage_resources
	desc = operation_targeted_sabotage_resources_desc
	priority = 15
	
	days = 90
	network_strength = 35
	operatives = 3

	visible = {
		num_of_operatives > 1
		network_national_coverage = {
			target = FROM
			value > 0
		}


		has_operation_token = {
			tag = FROM
			token = token_resistance_contacts
		}
	}
	
	requirements = {
		FROM = {
			any_controlled_state = {
				has_resistance = yes
			}
		}
	}
	selection_target_state = {
		has_resistance = yes
	}
	selection_target = {
		targets = { FROM }
	}
	required_tokens = { token_resistance_contacts }
	equipment = {
		
	}
	risk_chance = 0.2
	experience = 2
	outcome_extra_chance = 0.25
	outcome_modifiers = { target_sabotage_factor operation_outcome }
	risk_modifiers = { target_sabotage_risk operation_risk }
	cost_modifiers = { target_sabotage_cost operation_cost }
	outcome_execute = {
		FROM.FROM = {
			add_to_variable = {
				var = targeted_sabotage_resources
				value = 5
			}
			custom_effect_tooltip = targeted_sabotage_resources_2_tt
		}
		ROOT = {
			remove_operation_token = {
				tag = FROM
				token = token_resistance_contacts
			}
		}
	}
	outcome_extra_execute = { # SCOPE_OPERATION
		
		FROM.FROM = {
			add_to_variable = {
				var = targeted_sabotage_resources
				value = 8
			}
			custom_effect_tooltip = targeted_sabotage_resources_2_tt
		}
	}
	outcome_potential = {
		custom_effect_tooltip = operation_outcome_sabotage_resources_tt
		custom_effect_tooltip = operation_outcome_consumes_token_tt
	}
	phases = { #infiltration
		infiltration_border = { base = 25 }
		infiltration_submarine = { base = 25 }
		infiltration_paradrop = { 
			base = 25 
			modifier = {
				ROOT = { 
					has_equipment = {
						transport_plane_equipment < 1
					}
				}
				factor = 0
			}
		}
		infiltration_diplomatic = {
			base = 25
			modifier = {
				factor = 20
				ROOT = { has_war = no }
				FROM = {
					has_war = no
				}
			}
			modifier = {
				FROM = {
					has_war_with = ROOT
				}
				factor = 0
			}
		}
	}
	phases = {
		targeted_sabotage_burn_storage = { base = 50 }
		targeted_sabotage_destroy_mining_equipment = { base = 50 }
	}
	phases = { #exfiltration
		exfiltration_air_pickup = { 
			base = 15 
			modifier = {
				ROOT = { 
					has_equipment = {
						transport_plane_equipment < 1
					}
				}
				factor = 0
			}
		}
		exfiltration_border = { base = 30 }
		exfiltration_go_to_ground = { base = 30 }
		exfiltration_submarine_pickup = { base = 25 }
	}
}

raid_trotskys_villa = { ### 1/50
	icon = GFX_raid_trotskys_villa
	map_icon = GFX_raid_trotskys_villa_map
	name = raid_trotskys_villa
	desc = raid_trotskys_villa_desc
	days = 60

	priority = 11

	allowed = {
		original_tag = SOV
	}
	available = { 
		network_strength = {
			target = MEX
			state = 277
			value > 50
		}
	}
	visible = {
		has_completed_focus = SOV_behead_the_snake
		OR = {
			has_global_flag = trotsky_exile_mexico
			has_global_flag = flag_mexico_invited_trotsky_to_government
		}
		NOT = { has_global_flag = flag_trotsky_dead }
		NOT = { has_global_flag = flag_trotsky_has_returned_to_ussr_from_mexico }
		FROM = {
			controls_state = 277
		}
	}

	operatives = 1

	# Integer [0-100] - Every operation has a hard requirement of network strength in the target country
	network_strength = 50

	equipment = {
		infantry_equipment = 50
		support_equipment = 50
	}

	on_start = {  # SCOPE_OPERATION
		
	}

	outcome_modifiers = { operation_outcome }
	cost_modifiers = { operation_cost }
	risk_modifiers = { operation_risk }

	outcome_potential = {
		custom_effect_tooltip = raid_trotskys_villa_outcome_tt
	}
	risk_chance = 0.35
	experience = 5
	# outcome is an effect that runs when the operation has completed
	outcome_execute = { # SCOPE_OPERATION
		hidden_effect = {
			ROOT = { set_country_flag = SOV_raided_trotskys_villa_flag } #For AI Strat
		}
		ROOT = { news_event = { id = nsb_news.100 } } #SUCCESS - Kill Trotsky and swap Trotskyite Plot NS
	}

	outcome_extra_chance = 0.50

	outcome_extra_execute = {
		hidden_effect = {
			ROOT = { set_country_flag = SOV_raided_trotskys_villa_flag } #For AI Strat
		}
		ROOT = { news_event = { id = nsb_news.101 } } #FAILURE - Trotsky still alive
	}

	# This is where all the separate phases are defined
	# Each phase for an operation may have a single actual phase assigned to it, which is determined here
	phases = { #infiltration 
		infiltration_border = { base = 60 }
		infiltration_submarine = { base = 20 }
		infiltration_diplomatic = {
			base = 20
			modifier = {
				FROM = {
					has_war_with = ROOT
				}
				factor = 0
			}
		}
	}
	phases = { 
		raid_trotskys_villa_attack = { base = 100 }
	}
	phases = { 
		exfiltration_border = { base = 40 }
		exfiltration_go_to_ground = { base = 30 }
		exfiltration_submarine_pickup = { base = 20 }
		exfiltration_air_pickup = { 
			base = 10
			modifier = {
				ROOT = { 
					has_equipment = {
						transport_plane_equipment < 1
					}
				}
				factor = 0 #less likely if we have no transports
			}
		}
	}
}


murder_trotsky = { ### 1/50
	icon = GFX_murder_trotsky
	map_icon = GFX_murder_trotsky_map
	name = murder_trotsky
	desc = murder_trotsky_desc
	days = 270

	priority = 10

	allowed = {
		original_tag = SOV
	}
	available = {

	}
	visible = {
		has_completed_focus = SOV_behead_the_snake
		NOT = { has_global_flag = flag_trotsky_dead }
		NOT = { has_global_flag = flag_trotsky_has_returned_to_ussr_from_mexico }
		NOT = { ROOT = { has_country_flag = SOV_trotskys_assassination_attempt_flag } } # This operation can only be done once
		OR = {
			AND = {
				FROM = {
					controls_state = 277 #MEXICO CITY
				}
				OR = {
					has_global_flag = trotsky_exile_mexico
					has_global_flag = flag_mexico_invited_trotsky_to_government
				}	
			}
			AND = {
				FROM = {
					controls_state = 110 #OSTLANDET (Oslo) -> Trotsky not accepted in Mexico (or Soviets being super fast to kill him, which should be impossible btw)
				}
				NOT = {
					has_global_flag = trotsky_exile_mexico
					has_global_flag = flag_mexico_invited_trotsky_to_government
				}
			}
		}	
	}

	operatives = 1

	# Integer [0-100] - Every operation has a hard requirement of network strength in the target country
	network_strength = 25

	on_start = {  # SCOPE_OPERATION
		
	}

	outcome_modifiers = { operation_outcome operation_infiltrate_outcome }
	cost_modifiers = { operation_cost operation_infiltrate_cost }
	risk_modifiers = { operation_risk operation_infiltrate_risk }

	outcome_potential = {
		custom_effect_tooltip = murder_trotsky_outcome_tt
	}
	risk_chance = 0.25
	experience = 5
	# outcome is an effect that runs when the operation has completed
	outcome_execute = { # SCOPE_OPERATION
		ROOT = { set_country_flag = SOV_trotskys_assassination_attempt_flag } # This operation can only be done once
		ROOT = { news_event = { id = news.37 } }  #SUCCESS - Kill Trotsky and swap Trotskyite Plot NS
	}
	
	# This is where all the separate phases are defined
	# Each phase for an operation may have a single actual phase assigned to it, which is determined here
	phases = { #infiltration 
		murder_trotsky_infiltration = { base = 100 }
	}
	phases = { 
		murder_trotsky_attack = { base = 100 }
	}
	phases = { 
		exfiltration_border = { base = 40 }
		exfiltration_go_to_ground = { base = 30 }
		exfiltration_submarine_pickup = { base = 20 }
		exfiltration_air_pickup = { 
			base = 10
			modifier = {
				ROOT = { 
					has_equipment = {
						transport_plane_equipment < 1
					}
				}
				factor = 0 #less likely if we have no transports
			}
		}
	}
}

heavy_water_raid = { ### 1/50
	icon = GFX_historical_heavy_water
	map_icon = GFX_historical_heavy_water_small
	name = heavy_water_raid
	desc = heavy_water_raid_desc
	days = 90

	allowed = {
		NOT = { original_tag = GER }
	}
	available = { 
		has_global_flag = GER_heavy_water_production_underway
		has_war_with = GER
		110 = { resistance > 50 }
		OR = {
			network_strength = {
				target = GER
				state = 110
				value > 50
			}
			network_strength = {
				target = NOR
				state = 110
				value > 50
			}
		}
	}
	visible = {
		has_global_flag = GER_heavy_water_production_underway
		FROM = {
			OR = {
				original_tag = GER
				AND = {
					original_tag = NOR 
					is_subject_of = GER
				}
			}
		}
		OR = {
			AND = {
				GER = { controls_state = 110 }
				network_national_coverage = {
					target = GER
					value > 0
				}
			}
			AND = {
				NOR = { controls_state = 110 }
				network_national_coverage = {
					target = NOR
					value > 0
				}
			}
		}
	}	

	operatives = 1

	# Integer [0-100] - Every operation has a hard requirement of network strength in the target country
	network_strength = 50

	equipment = {
		infantry_equipment = 500
		support_equipment = 50
	}

	on_start = {  # SCOPE_OPERATION
		
	}

	outcome_modifiers = { operation_outcome }
	cost_modifiers = { operation_cost }
	risk_modifiers = { operation_risk }

	outcome_potential = {
		custom_effect_tooltip = heavy_water_raid_outcome_tt
	}
	risk_chance = 0.50
	experience = 5
	# outcome is an effect that runs when the operation has completed
	outcome_execute = { # SCOPE_OPERATION
		FROM = { country_event = lar_heavy_water.1 }
		ROOT = { country_event = lar_heavy_water.2 }
	}
	
	# This is where all the separate phases are defined
	# Each phase for an operation may have a single actual phase assigned to it, which is determined here
	phases = { #infiltration 
		heavy_water_infiltration = { base = 100 }
	}
	phases = { 
		heavy_water_attack = { base = 100 }
	}
	phases = { 
		heavy_water_exfiltration = { base = 100 }
	}
}
