# NCE stable port: MD 2.0 raid logic retained; beta NCE battalion eligibility additions reapplied only to pre-existing modified raids.
types = {
	#Attacks mess with enemy units (large drone swarm of suicide drones)
	drone_swarm_strikes = {
		days_to_prepare = 5
		days_re_enable = 1

		category = drone_strike_raids

		command_power = 20 # command power allocation cost
		speed_multiplier = 10

		arrow = {
			type = air
		}

		# Specific Target is visible
		show_target = {
			OR = {
				has_war_with = FROM
				has_wargoal_against = FROM
				is_justifying_wargoal_against = FROM
			}
			FROM = {
				divisions_in_state = {
					size > 0
					state = var:target_state
				}
			}
		}

		# Can prepare
		available = {
			drone_raid_available_hostile = yes
		}

		launchable = {
			has_war_with = FROM
		}

		target_type = {
			state = {
				always = yes
			}
		}

		unit_requirements = {
			battalion_types = {
				drone_tactical_company = { min = 1 }
			}
		}
		# NCE: alternative eligible formation
		unit_requirements = {
			battalion_types = {
				XS_drone_tactical_company = { min = 1 }
			}
		}

		# NCE: alternative eligible formation
		unit_requirements = {
			battalion_types = {
				Team_drone_tactical_company = { min = 1 }
			}
		}

		essential_equipment = {
			medium_plane_suicide_airframe = 1000
		}
		target_icon = GFX_other_target_icon
		launch_sound = raid_launch_air

		starting_point = {
			types = { air_base }
		}
		success_factors = {
			success = {
				base = 0.15

				# Raiding unit modifiers
				experience = {
					weight = 0.2
					start_weight = -0.2
					reference = 0.5
				}

				organisation = {
					weight = 0.3
					start_weight = -0.3
					reference = 60
				}
				strength = {
					weight = 0.05
					start_weight = -0.05
					reference = 1
				}
				recon = {
					weight = 0.5
					start_weight = -0.05
					reference = 10
				}

				### Target Modifiers
				resistance = {
					reference = 100
					start_reference = 20 # Resistance below 20 doesn't help
					weight = 0.4
				}
				radar = {
					reference = 1
					weight = -0.15
				}
				anti_air = {
					reference = 5
					weight = -0.25
				}
				intel = {
					weight = 0.5
					start_weight = -0.1
					start_reference = 10
					reference = 100
				}
			}

			disaster = {
				base = 0.25
			}

			critical = {
				base = 0.05
			}
		}

		success_levels = {
			failure = {
				# Other unit effects
				division_effects = {
					add_divisional_commander_xp = 50
				}
			}
			limited_success = {
				victim_effects = {
					set_temp_variable_to_random = { var = missile_luck_mod min = 0.4 max = 0.6 }
					set_temp_variable = { drone_damage_spread = 125 }
					apply_drone_swarm_damage = yes
				}
			}
			success = {
				victim_effects = {
					set_temp_variable_to_random = { var = missile_luck_mod min = 0.6 max = 0.8 }
					set_temp_variable = { drone_damage_spread = 130 }
					apply_drone_swarm_damage = yes
				}
			}
			critical_success = {
				victim_effects = {
					set_temp_variable_to_random = { var = missile_luck_mod min = 0.8 max = 1 }
					set_temp_variable = { drone_damage_spread = 135 }
					apply_drone_swarm_damage = yes
				}
			}
		}


		ai_will_do = {
			base = 0
			modifier = {
				add = 5
				has_opinion = {
					target = FROM
					value < -50
				}
			}
			modifier = {
				add = 5
				has_opinion = {
					target = FROM
					value < -75
				}
			}
			modifier = {
				add = -10
				has_government = FROM
			}
			modifier = {
				factor = 0
				threat < 0.10
				raid_skip_target_non_hostile_no_retaliation = yes
			}
			modifier = {
				factor = 0.05
				OR = {
					has_government = democratic
					has_government = neutrality
					has_elections = yes
				}
				FROM = { has_added_tension_amount < 5 }
			}
			modifier = {
				factor = 0
				date < 2001.1.1
				raid_skip_target_non_hostile_no_retaliation = yes
			}
			modifier = {
				NOT = {
					has_country_flag = promised_retaliation_against@FROM
				}
				factor = 0
				FROM = {
					OR = {
						has_idea = NATO_member
						has_idea = CSTO_member
						has_idea = EU_member
						has_idea = faction_resistance_axis_member
					}
				}
			}
			# Alliance gate — back off when target is in a faction and our alliance ratio is weak (<0.7)
			modifier = {
				factor = 0
				raid_alliance_unfavorable = yes
			}
			# Doctrinal reach gate — isolation/local_security/limited interventionism can't reach.
			# Bypassed by the rule_raid_doctrine_reach game rule.
			modifier = {
				factor = 0
				raid_intervention_doctrine_reach_block = yes
			}
			# Major-power target dampener — AI minors are 4× less likely to raid super/great powers while at peace.
			modifier = {
				factor = 0.25
				raid_skip_target_non_hostile_no_retaliation = yes
				FROM = {
					OR = { has_idea = super_power has_idea = great_power }
				}
				NOT = { OR = { has_idea = super_power has_idea = great_power } }
			}
			modifier = {
				has_country_flag = promised_retaliation_against@FROM
				factor = 100
			}
			modifier = {
				has_country_flag = conceded_to@FROM
				factor = 0
			}
			modifier = {
				# Don't raid nations we have influence in
				factor = 0
				raid_skip_target_non_hostile_no_retaliation = yes
				FROM = { is_influencer = yes }
			}
			modifier = {
				# Don't raid if heavily in debt
				factor = 0
				raid_skip_target_non_hostile_no_retaliation = yes
				check_variable = { debt_ratio > 0.25 }
			}
			modifier = {
				# Less likely to raid if somewhat in debt
				factor = 0.25
				NOT = { has_war_with = FROM }
				check_variable = { debt_ratio > 0.15 }
			}
			modifier = {
				factor = 0
				is_ally_with = FROM
				raid_skip_target_non_hostile_no_retaliation = yes
			}
			modifier = {
				factor = 0
				OR = {
					FROM = { is_subject_of = ROOT }
					is_subject_of = FROM
				}
			}
		}
	}
	#Targeted Recon missions for the main drones
	drone_target_recon = {
		days_to_prepare = 5
		days_re_enable = 90

		category = drone_strike_raids

		command_power = 20 # command power allocation cost

		arrow = {
			type = line
		}

		# Specific Target is visible
		show_target = {
			OR = {
				has_war_with = FROM
				has_wargoal_against = FROM
				is_justifying_wargoal_against = FROM
			}
		}

		# Can prepare
		available = {
			FROM = {
				NOT = {
					is_subject_of = ROOT
				}
				NOT = {
					has_non_aggression_pact_with = ROOT
				}
			}
			OR = {
				hidden_trigger = {
					has_country_flag = promised_retaliation_against@FROM
				}
				has_war_with = FROM
				has_wargoal_against = FROM
				set_temp_variable = { cost = 300 }
				raid_can_launch = yes
				is_justifying_wargoal_against = FROM
			}
		}

		launchable = {
			has_war_with = FROM
		}

		target_type = {
			building = {
				type = supply_node
			}
		}


		unit_requirements = {
			equipment = {
				type = { small_plane_suicide_airframe cv_small_plane_suicide_airframe }
				amount = { min = 20 }
			}
		}

		target_icon = GFX_other_target_icon
		launch_sound = raid_launch_air

		starting_point = {
			types = { air_base }
		}
		success_factors = {
			success = {
				base = 0.15

				# Raiding unit modifiers
				experience = {
					weight = 0.3
					start_weight = -0.2
					reference = 1000
				}
				air_agility = {
					reference = 200
					weight = 0.5
					start_weight = -0.5
				}
				reliability = {
					reference = 1
					weight = 0.2
					start_weight = -0.1
				}
				air_defence = {
					reference = 150
					weight = 0.2
					start_weight = -0.2
				}
				air_superiority = {
					reference = 1
					weight = 0.1
					start_weight = -0.10
				}

				### Target Modifiers
				anti_air = {
					reference = 5
					weight = -0.25
				}
				radar = {
					reference = 1
					weight = -0.15
				}
				interception = {
					reference = 120 # 5 wings as 500 planes in vanilla
					weight = -0.2
				}
				intel = {
					weight = 0.5
					start_weight = -0.1
					start_reference = 10
					reference = 100
				}
			}

			disaster = {
				base = 0.25
			}

			critical = {
				base = 0.05
			}
		}

		success_levels = {
			failure = {
				victim_effects = {
					# Effects on target
				}
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -300 }
					apply_raid_failure_losses = yes
				}
				# Other unit effects
			}
			limited_success = {
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -300 }
					apply_raid_limited_success_losses = yes
					var:actor_country = {
						add_timed_idea = {
							idea = targeted_drone_recon
							days = 20
						}
					}
				}

			}
			success = {
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -300 }
					apply_raid_success_losses = yes
					var:actor_country = {
						add_timed_idea = {
							idea = targeted_drone_recon
							days = 40
						}
					}
				}
			}
			critical_success = {
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -300 }
					apply_raid_critical_success_losses = yes
					var:actor_country = {
						add_timed_idea = {
							idea = targeted_drone_recon
							days = 60
						}
					}
				}
			}
		}

		ai_will_do = {
			base = 0
			modifier = {
				add = 5
				has_opinion = {
					target = FROM
					value < -50
				}
			}
			modifier = {
				add = 5
				has_opinion = {
					target = FROM
					value < -75
				}
			}
			modifier = {
				add = -10
				has_government = FROM
			}
			modifier = {
				factor = 0
				threat < 0.10
				raid_skip_target_non_hostile_no_retaliation = yes
			}
			modifier = {
				factor = 0.05
				OR = {
					has_government = democratic
					has_government = neutrality
					has_elections = yes
				}
				FROM = { has_added_tension_amount < 5 }
			}
			modifier = {
				factor = 0
				date < 2001.1.1
				raid_skip_target_non_hostile_no_retaliation = yes
			}
			modifier = {
				NOT = {
					has_country_flag = promised_retaliation_against@FROM
				}
				factor = 0
				FROM = {
					OR = {
						has_idea = NATO_member
						has_idea = CSTO_member
						has_idea = EU_member
						has_idea = faction_resistance_axis_member
					}
				}
			}
			# Alliance gate — back off when target is in a faction and our alliance ratio is weak (<0.7)
			modifier = {
				factor = 0
				raid_alliance_unfavorable = yes
			}
			# Doctrinal reach gate — isolation/local_security/limited interventionism can't reach.
			# Bypassed by the rule_raid_doctrine_reach game rule.
			modifier = {
				factor = 0
				raid_intervention_doctrine_reach_block = yes
			}
			# Major-power target dampener — AI minors are 4× less likely to raid super/great powers while at peace.
			modifier = {
				factor = 0.25
				raid_skip_target_non_hostile_no_retaliation = yes
				FROM = {
					OR = { has_idea = super_power has_idea = great_power }
				}
				NOT = { OR = { has_idea = super_power has_idea = great_power } }
			}
			modifier = {
				has_country_flag = promised_retaliation_against@FROM
				factor = 100
			}
			modifier = {
				has_country_flag = conceded_to@FROM
				factor = 0
			}
			modifier = {
				# Don't raid nations we have influence in
				factor = 0
				raid_skip_target_non_hostile_no_retaliation = yes
				FROM = { is_influencer = yes }
			}
			modifier = {
				# Don't raid if heavily in debt
				factor = 0
				raid_skip_target_non_hostile_no_retaliation = yes
				check_variable = { debt_ratio > 0.25 }
			}
			modifier = {
				# Less likely to raid if somewhat in debt
				factor = 0.25
				NOT = { has_war_with = FROM }
				check_variable = { debt_ratio > 0.15 }
			}
			modifier = {
				factor = 0
				is_ally_with = FROM
				raid_skip_target_non_hostile_no_retaliation = yes
			}
			modifier = {
				factor = 0
				OR = {
					FROM = { is_subject_of = ROOT }
					is_subject_of = FROM
				}
			}
		}
	}
	#Targeted drone strike on a facility, able to be done at peace
	targeted_drone_strike = {
		days_to_prepare = 90
		days_re_enable = 270

		category = drone_strike_raids

		command_power = 20 # command power allocation cost

		arrow = {
			type = air
		}

		# Raid Type is visible
		visible = {
			set_temp_variable = { cost = 300 }
			raid_can_launch = yes
		}
		# Specific Target is visible
		show_target = {
			NOT = { is_in_faction_with = FROM }
			raid_show_target_opinion_neutral = yes
		}

		# Can prepare
		available = {
			FROM = {
				NOT = {
					is_subject_of = ROOT
				}
				NOT = {
					has_non_aggression_pact_with = ROOT
				}
			}
			set_temp_variable = { cost = 300 }
			raid_can_launch = yes
		}

		target_type = {
			building = {
				tags = facility
			}
		}

		unit_requirements = {
			equipment = {
				type = { small_plane_suicide_airframe cv_small_plane_suicide_airframe }
				amount = { min = 20 }
			}
		}

		target_icon = GFX_other_target_icon
		launch_sound = raid_launch_air

		starting_point = {
			types = { air_base }
		}
		success_factors = {
			success = {
				base = 0.15

				# Raiding unit modifiers
				experience = {
					weight = 0.3
					start_weight = -0.2
					reference = 1000
				}
				air_agility = {
					reference = 200
					weight = 0.5
					start_weight = -0.5
				}
				reliability = {
					reference = 1
					weight = 0.2
					start_weight = -0.1
				}
				air_defence = {
					reference = 150
					weight = 0.2
					start_weight = -0.2
				}
				air_superiority = {
					reference = 1
					weight = 0.1
					start_weight = -0.10
				}

				### Target Modifiers
				anti_air = {
					reference = 5
					weight = -0.25
				}
				radar = {
					reference = 1
					weight = -0.15
				}
				interception = {
					reference = 120 # 5 wings as 500 planes in vanilla
					weight = -0.2
				}
				intel = {
					weight = 0.5
					start_weight = -0.1
					start_reference = 10
					reference = 100
				}
			}

			disaster = {
				base = 0.25
			}

			critical = {
				base = 0.05
			}
		}

		success_levels = {
			failure = {
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -100 }
					apply_raid_failure_losses = yes
				}
				victim_effects = {
					send_raid_event_to_victim = yes
				}
			}
			limited_success = {
				victim_effects = {
					send_raid_event_to_victim = yes

					calculate_aa_defense_value = yes
					set_temp_variable = { building_damage_by_missile = 1.25 }

					set_temp_variable = { raid_damage_mult = 25 }
					apply_raid_building_damage_limited = yes

					clamp_temp_variable = {
						var = building_damage_by_missile
						max = 1
					}

					if = { limit = { check_variable = { building_damage_by_missile < 1 } } set_temp_variable = { building_damage_by_missile = 1.25 } }



					var:target_state = {
						meta_effect = {
							text = {
								damage_building = {
									tags = facility
									damage = [DAM]
									province = var:ROOT.target_province
								}
							}
							DAM = "[?building_damage_by_missile]"
						}
					}
					var:victim_country = {
						random_active_scientist = {
							injure_scientist_for_days = 10
						}
					}
				}
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -300 }
					apply_raid_limited_success_losses = yes
				}
			}
			success = {
				victim_effects = {
					send_raid_event_to_victim = yes

					calculate_aa_defense_value = yes
					set_temp_variable = { building_damage_by_missile = 1.25 }

					set_temp_variable = { raid_damage_mult = 25 }
					apply_raid_building_damage_success = yes

					clamp_temp_variable = {
						var = building_damage_by_missile
						max = 1
					}

					if = { limit = { check_variable = { building_damage_by_missile < 1 } } set_temp_variable = { building_damage_by_missile = 1.25 } }

					multiply_temp_variable = { building_damage_by_missile = 0.5 }

					var:target_state = {
						meta_effect = {
							text = {
								damage_building = {
									tags = facility
									damage = [DAM]
									province = var:ROOT.target_province
								}
							}
							DAM = "[?building_damage_by_missile]"
						}
					}
					var:victim_country = {
						random_active_scientist = {
							injure_scientist_for_days = 10
						}
					}
				}
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -300 }
					apply_raid_success_losses = yes
				}
			}
			critical_success = {
				victim_effects = {
					send_raid_event_to_victim = yes

					calculate_aa_defense_value = yes
					set_temp_variable = { building_damage_by_missile = 1.25 }

					set_temp_variable = { raid_damage_mult = 25 }
					apply_raid_building_damage_critical = yes

					clamp_temp_variable = {
						var = building_damage_by_missile
						max = 1
					}

					if = { limit = { check_variable = { building_damage_by_missile < 1 } } set_temp_variable = { building_damage_by_missile = 1.25 } }

					multiply_temp_variable = { building_damage_by_missile = 0.75 }

					var:target_state = {
						meta_effect = {
							text = {
								damage_building = {
									tags = facility
									damage = [DAM]
									province = var:ROOT.target_province
								}
							}
							DAM = "[?building_damage_by_missile]"
						}
					}
					var:victim_country = {
						random_active_scientist = {
							injure_scientist_for_days = 10
						}
					}
				}
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -300 }
					apply_raid_critical_success_losses = yes
				}
			}
		}

		ai_will_do = {
			base = 0
			modifier = {
				add = 5
				has_opinion = {
					target = FROM
					value < -50
				}
			}
			modifier = {
				add = 5
				has_opinion = {
					target = FROM
					value < -75
				}
			}
			modifier = {
				add = 5
				has_opinion = {
					target = FROM
					value < -50
				}
			}
			modifier = {
				factor = 0
				threat < 0.10
				raid_skip_target_non_hostile_no_retaliation = yes
			}
			modifier = {
				add = -10
				has_government = FROM
			}
			modifier = {
				factor = 0.05
				OR = {
					has_government = democratic
					has_government = neutrality
					has_elections = yes
				}
				FROM = { has_added_tension_amount < 5 }
			}
			modifier = {
				factor = 0
				date < 2001.1.1
				raid_skip_target_non_hostile_no_retaliation = yes
			}
			modifier = {
				NOT = {
					has_country_flag = promised_retaliation_against@FROM
				}
				factor = 0
				FROM = {
					OR = {
						has_idea = NATO_member
						has_idea = CSTO_member
						has_idea = EU_member
						has_idea = faction_resistance_axis_member
					}
				}
			}
			# Alliance gate — back off when target is in a faction and our alliance ratio is weak (<0.7)
			modifier = {
				factor = 0
				raid_alliance_unfavorable = yes
			}
			# Doctrinal reach gate — isolation/local_security/limited interventionism can't reach.
			# Bypassed by the rule_raid_doctrine_reach game rule.
			modifier = {
				factor = 0
				raid_intervention_doctrine_reach_block = yes
			}
			# Major-power target dampener — AI minors are 4× less likely to raid super/great powers while at peace.
			modifier = {
				factor = 0.25
				raid_skip_target_non_hostile_no_retaliation = yes
				FROM = {
					OR = { has_idea = super_power has_idea = great_power }
				}
				NOT = { OR = { has_idea = super_power has_idea = great_power } }
			}
			modifier = {
				has_country_flag = promised_retaliation_against@FROM
				factor = 100
			}
			modifier = {
				has_country_flag = conceded_to@FROM
				factor = 0
			}
			modifier = {
				# Don't raid nations we have influence in
				factor = 0
				raid_skip_target_non_hostile_no_retaliation = yes
				FROM = { is_influencer = yes }
			}
			modifier = {
				# Don't raid if heavily in debt
				factor = 0
				raid_skip_target_non_hostile_no_retaliation = yes
				check_variable = { debt_ratio > 0.25 }
			}
			modifier = {
				# Less likely to raid if somewhat in debt
				factor = 0.25
				NOT = { has_war_with = FROM }
				check_variable = { debt_ratio > 0.15 }
			}
			modifier = {
				factor = 0
				is_ally_with = FROM
				raid_skip_target_non_hostile_no_retaliation = yes
			}
			modifier = {
				factor = 0
				OR = {
					FROM = { is_subject_of = ROOT }
					is_subject_of = FROM
				}
			}
		}
	}

	counter_terror_drone_operations = {
		days_to_prepare = 14
		days_re_enable = 30

		category = drone_strike_raids

		command_power = 20 # command power allocation cost

		arrow = {
			type = line
		}

		# Visible once the drone op has been prepared against this target and we have
		# doctrine reach (limited = neighbour, regional = same continent).
		show_target = {
			raid_show_target_intervention_check = yes
			FROM = {
				has_country_flag = ct_drone_op_prepared_by@ROOT
			}
		}

		available = {
			FROM = {
				NOT = { is_subject_of = ROOT }
				NOT = { has_non_aggression_pact_with = ROOT }
			}
			set_temp_variable = { cost = 150 }
			raid_can_launch = yes
		}

		launchable = {
			set_temp_variable = { cost = 150 }
			raid_can_launch = yes
		}

		target_type = {
			state = {
				is_capital = yes
			}
		}

		unit_requirements = {
			equipment = {
				type = { small_plane_suicide_airframe cv_small_plane_suicide_airframe }
				amount = { min = 1 }
			}
		}

		launch_sound = raid_launch_marine
		target_icon = GFX_other_target_icon
		starting_point = {
			types = { air_base }
		}
		success_factors = {
			success = {
				base = 0.15

				# Raiding unit modifiers
				experience = {
					weight = 0.3
					start_weight = -0.2
					reference = 1000
				}
				air_agility = {
					reference = 200
					weight = 0.5
					start_weight = -0.5
				}
				reliability = {
					reference = 1
					weight = 0.2
					start_weight = -0.1
				}
				air_defence = {
					reference = 150
					weight = 0.2
					start_weight = -0.2
				}
				air_superiority = {
					reference = 1
					weight = 0.1
					start_weight = -0.10
				}

				### Target Modifiers
				anti_air = {
					reference = 5
					weight = -0.25
				}
				radar = {
					reference = 1
					weight = -0.15
				}
				interception = {
					reference = 120 # 5 wings as 500 planes in vanilla
					weight = -0.2
				}
				intel = {
					weight = 0.5
					start_weight = -0.1
					start_reference = 10
					reference = 100
				}
			}

			critical = {
				base = 0.05
			}

			disaster = {
				base = 0.05
			}
		}

		success_levels = {
			failure = {
				victim_effects = {
					send_raid_event_to_victim = yes
					send_ct_raid_events_to_victim = yes
				}
				actor_effects = {
					var:target_state = {
						ct_resolve_raid_org = yes
					}
					if = {
						limit = { check_variable = { targeted_org > -1 } }
						var:actor_country = {
							randomize_temp_variable = {
								var = threat_loss
								distribution = poisson
								min = 2
								lambda = 8
							}
							add_to_variable = { global.active_terror_org_threat_lvl^targeted_org = threat_loss }
							multiply_temp_variable = { threat_loss = -1 }
							add_to_variable = { global.active_terror_org_vis_lvl^targeted_org = threat_loss }
						}
					}
				}
			}
			limited_success = {
				victim_effects = {
					send_raid_event_to_victim = yes
					send_ct_raid_events_to_victim = yes
				}
				actor_effects = {
					var:target_state = {
						ct_resolve_raid_org = yes
					}
					if = {
						limit = { check_variable = { targeted_org > -1 } }
						var:actor_country = {
							randomize_temp_variable = {
								var = intel_gain
								distribution = poisson
								min = 1
								lambda = 5
							}
							add_to_variable = { international_terror_org_temp_specific_intel^targeted_org = intel_gain }
							randomize_temp_variable = {
								var = threat_loss
								distribution = poisson
								min = -5
								lambda = -1
							}
							add_to_variable = { global.active_terror_org_threat_lvl^targeted_org = threat_loss }
							multiply_temp_variable = { threat_loss = -1 }
							add_to_variable = { global.active_terror_org_vis_lvl^targeted_org = threat_loss }
						}
					}
				}

			}
			success = {
				victim_effects = {
					send_raid_event_to_victim = yes
					send_ct_raid_events_to_victim = yes
				}
				actor_effects = {
					var:target_state = {
						ct_resolve_raid_org = yes
					}
					if = {
						limit = { check_variable = { targeted_org > -1 } }
						var:actor_country = {
							randomize_temp_variable = {
								var = intel_gain
								distribution = poisson
								min = 1
								lambda = 10
							}
							add_to_variable = { international_terror_org_temp_specific_intel^targeted_org = intel_gain }
							randomize_temp_variable = {
								var = threat_loss
								distribution = poisson
								min = -10
								lambda = -1
							}
							add_to_variable = { global.active_terror_org_threat_lvl^targeted_org = threat_loss }
							multiply_temp_variable = { threat_loss = -1 }
							add_to_variable = { global.active_terror_org_vis_lvl^targeted_org = threat_loss }
						}
					}
				}
			}
			critical_success = {
				victim_effects = {
					send_raid_event_to_victim = yes
					send_ct_raid_events_to_victim = yes
				}
				actor_effects = {
					var:target_state = {
						ct_resolve_raid_org = yes
					}
					if = {
						limit = { check_variable = { targeted_org > -1 } }
						var:actor_country = {
							randomize_temp_variable = {
								var = intel_gain
								distribution = poisson
								min = 1
								lambda = 15
							}
							add_to_variable = { international_terror_org_temp_specific_intel^targeted_org = intel_gain }
							randomize_temp_variable = {
								var = threat_loss
								distribution = poisson
								min = -15
								lambda = -1
							}
							add_to_variable = { global.active_terror_org_threat_lvl^targeted_org = threat_loss }
							multiply_temp_variable = { threat_loss = -1 }
							add_to_variable = { global.active_terror_org_vis_lvl^targeted_org = threat_loss }
						}
					}
				}
			}
		}

		ai_will_do = {
			base = 0
			# Execute when CT drone op has been prepared
			modifier = {
				add = 50
				FROM = { has_country_flag = ct_drone_op_prepared_by@ROOT }
			}
			modifier = {
				factor = 2
				OR = {
					has_idea = super_power
					has_idea = great_power
				}
			}
			modifier = {
				factor = 2
				has_country_flag = ct_recently_attacked
			}
		}
	}

	#Suicide drone strikes against airfields and radar stations
	drone_airfield_radar_strike = {
		days_to_prepare = 7
		days_re_enable = 90

		category = drone_strike_raids

		command_power = 20
		speed_multiplier = 10

		arrow = {
			type = air
		}

		# Visible if we have a war/wargoal motive, OR opinion < 0 plus doctrine reach.
		# Restricted to states that actually contain an air base or radar to target.
		show_target = {
			OR = {
				has_war_with = FROM
				has_wargoal_against = FROM
				is_justifying_wargoal_against = FROM
				AND = {
					has_opinion = {
						target = FROM
						value < 0
					}
					raid_show_target_intervention_check = yes
				}
			}
			FROM = { MD_special_countries = no }
		}

		# Can prepare
		available = {
			drone_raid_available_hostile = yes
		}

		launchable = {
			has_war_with = FROM
		}

		target_type = {
			building = {
				type = air_base
			}
			building = {
				type = radar_station
			}
		}

		unit_requirements = {
			battalion_types = {
				drone_tactical_company = { min = 1 }
			}
		}
		# NCE: alternative eligible formation
		unit_requirements = {
			battalion_types = {
				XS_drone_tactical_company = { min = 1 }
			}
		}

		# NCE: alternative eligible formation
		unit_requirements = {
			battalion_types = {
				Team_drone_tactical_company = { min = 1 }
			}
		}

		essential_equipment = {
			medium_plane_suicide_airframe = 500
		}

		target_icon = GFX_other_target_icon
		launch_sound = raid_launch_air

		starting_point = {
			types = { air_base }
		}

		success_factors = {
			success = {
				base = 0.15

				# Raiding unit modifiers
				experience = {
					weight = 0.2
					start_weight = -0.2
					reference = 0.5
				}
				organisation = {
					weight = 0.3
					start_weight = -0.3
					reference = 60
				}
				recon = {
					weight = 0.5
					start_weight = -0.05
					reference = 10
				}
				intel = {
					weight = 0.5
					start_weight = -0.1
					start_reference = 10
					reference = 100
				}

				### Target Modifiers
				anti_air = {
					reference = 5
					weight = -0.25
				}
				radar = {
					reference = 1
					weight = -0.15
				}
				interception = {
					reference = 500
					weight = -0.2
				}
			}

			disaster = {
				base = 0.25
			}

			critical = {
				base = 0.05
			}
		}

		success_levels = {
			failure = {
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -300 }
					apply_raid_failure_losses = yes
				}
				victim_effects = {
					send_raid_event_to_victim = yes
				}
			}

			limited_success = {
				victim_effects = {
					send_raid_event_to_victim = yes

					var:target_state = {
						set_temp_variable = { ROOT.airbase_tgt = THIS.building_level@air_base }
						set_temp_variable = { ROOT.radar_tgt = THIS.building_level@radar_station }
					}

					calculate_aa_defense_value = yes

					set_temp_variable = { building_damage_by_missile = 1.0 }

					set_temp_variable = { raid_damage_mult = 30 }
					apply_raid_building_damage_limited = yes

					set_temp_variable = { damage_split = 0 }

					if = {
						limit = {
							check_variable = { airbase_tgt > 0 }
						}
						add_to_temp_variable = { damage_split = 1 }
					}

					if = {
						limit = {
							check_variable = { radar_tgt > 0 }
						}
						add_to_temp_variable = { damage_split = 1 }
					}

					if = {
						limit = {
							check_variable = { damage_split > 1 }
						}
						divide_temp_variable = { building_damage_by_missile = damage_split }
					}

					set_temp_variable = { max_clamp = airbase_tgt }
					add_to_temp_variable = { max_clamp = radar_tgt }

					clamp_temp_variable = {
						var = building_damage_by_missile
						min = 0
						max = max_clamp
					}

					#ensure any raid does a minimum of 1 damage
					if = { limit = { check_variable = { building_damage_by_missile < 1 } } set_temp_variable = { building_damage_by_missile = 1.0 } }

					var:target_state = {
						if = { limit = { air_base > 0 }
							meta_effect = {
								text = {
									damage_building = {
										type = air_base
										damage = [DAM]
									}
								}
								DAM = "[?building_damage_by_missile]"
							}
						}
						if = { limit = { radar_station > 0 }
							meta_effect = {
								text = {
									damage_building = {
										type = radar_station
										damage = [DAM]
									}
								}
								DAM = "[?building_damage_by_missile]"
							}
						}
					}
				}
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -300 }
					apply_raid_limited_success_losses = yes
				}
			}

			success = {
				victim_effects = {
					send_raid_event_to_victim = yes

					var:target_state = {
						set_temp_variable = { ROOT.airbase_tgt = THIS.building_level@air_base }
						set_temp_variable = { ROOT.radar_tgt = THIS.building_level@radar_station }
					}

					calculate_aa_defense_value = yes

					set_temp_variable = { building_damage_by_missile = 1.0 }

					set_temp_variable = { raid_damage_mult = 50 }
					apply_raid_building_damage_success = yes

					set_temp_variable = { damage_split = 0 }

					if = {
						limit = {
							check_variable = { airbase_tgt > 0 }
						}
						add_to_temp_variable = { damage_split = 1 }
					}

					if = {
						limit = {
							check_variable = { radar_tgt > 0 }
						}
						add_to_temp_variable = { damage_split = 1 }
					}

					if = {
						limit = {
							check_variable = { damage_split > 1 }
						}
						divide_temp_variable = { building_damage_by_missile = damage_split }
					}

					set_temp_variable = { max_clamp = airbase_tgt }
					add_to_temp_variable = { max_clamp = radar_tgt }

					clamp_temp_variable = {
						var = building_damage_by_missile
						min = 0
						max = max_clamp
					}

					if = { limit = { check_variable = { building_damage_by_missile < 1 } } set_temp_variable = { building_damage_by_missile = 1.0 } }

					var:target_state = {
						if = { limit = { air_base > 0 }
							meta_effect = {
								text = {
									damage_building = {
										type = air_base
										damage = [DAM]
									}
								}
								DAM = "[?building_damage_by_missile]"
							}
						}
						if = { limit = { radar_station > 0 }
							meta_effect = {
								text = {
									damage_building = {
										type = radar_station
										damage = [DAM]
									}
								}
								DAM = "[?building_damage_by_missile]"
							}
						}
					}
				}
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -300 }
					apply_raid_success_losses = yes
				}
			}

			critical_success = {
				victim_effects = {
					send_raid_event_to_victim = yes

					var:target_state = {
						set_temp_variable = { ROOT.airbase_tgt = THIS.building_level@air_base }
						set_temp_variable = { ROOT.radar_tgt = THIS.building_level@radar_station }
					}

					calculate_aa_defense_value = yes

					set_temp_variable = { building_damage_by_missile = 1.0 }

					set_temp_variable = { raid_damage_mult = 70 }
					apply_raid_building_damage_critical = yes

					set_temp_variable = { damage_split = 0 }

					if = {
						limit = {
							check_variable = { airbase_tgt > 0 }
						}
						add_to_temp_variable = { damage_split = 1 }
					}

					if = {
						limit = {
							check_variable = { radar_tgt > 0 }
						}
						add_to_temp_variable = { damage_split = 1 }
					}

					if = {
						limit = {
							check_variable = { damage_split > 1 }
						}
						divide_temp_variable = { building_damage_by_missile = damage_split }
					}

					set_temp_variable = { max_clamp = airbase_tgt }
					add_to_temp_variable = { max_clamp = radar_tgt }

					clamp_temp_variable = {
						var = building_damage_by_missile
						min = 0
						max = max_clamp
					}

					if = { limit = { check_variable = { building_damage_by_missile < 1 } } set_temp_variable = { building_damage_by_missile = 1.0 } }

					var:target_state = {
						if = { limit = { air_base > 0 }
							meta_effect = {
								text = {
									damage_building = {
										type = air_base
										damage = [DAM]
									}
								}
								DAM = "[?building_damage_by_missile]"
							}
						}
						if = { limit = { radar_station > 0 }
							meta_effect = {
								text = {
									damage_building = {
										type = radar_station
										damage = [DAM]
									}
								}
								DAM = "[?building_damage_by_missile]"
							}
						}
					}
				}
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -300 }
					apply_raid_critical_success_losses = yes
				}
			}
		}

		ai_will_do = {
			base = 0

			modifier = {
				add = 5
				has_war_with = FROM
			}
			modifier = {
				add = 3
				FROM = {
					has_idea = air_power
				}
			}
			modifier = {
				factor = 0
				NOT = { has_war_with = FROM }
				FROM = {
					OR = {
						has_idea = NATO_member
						has_idea = CSTO_member
						has_idea = EU_member
						has_idea = faction_resistance_axis_member
					}
				}
			}
			# Alliance gate — back off when target is in a faction and our alliance ratio is weak (<0.7)
			modifier = {
				factor = 0
				raid_alliance_unfavorable = yes
			}
			# Doctrinal reach gate — isolation/local_security/limited interventionism can't reach.
			# Bypassed by the rule_raid_doctrine_reach game rule.
			modifier = {
				factor = 0
				raid_intervention_doctrine_reach_block = yes
			}
			modifier = {
				has_country_flag = conceded_to@FROM
				factor = 0
			}
			modifier = {
				factor = 0
				is_ally_with = FROM
				raid_skip_target_non_hostile_no_retaliation = yes
			}
			modifier = {
				factor = 0
				OR = {
					FROM = { is_subject_of = ROOT }
					is_subject_of = FROM
				}
			}
			modifier = {
				# Don't raid nations we have influence in
				factor = 0
				NOT = { has_country_flag = promised_retaliation_against@FROM }
				FROM = { is_influencer = yes }
			}
		}
	}

	#Suicide drone strikes against power plants and energy infrastructure
	drone_power_grid_strike = {
		days_to_prepare = 14
		days_re_enable = 120

		category = drone_strike_raids

		command_power = 20
		speed_multiplier = 10

		arrow = {
			type = air
		}

		# Specific Target is visible
		show_target = {
			NOT = { is_in_faction_with = FROM }
			FROM = {
				NOT = {
					has_country_flag = power_grid_damaged
				}
				MD_special_countries = no
			}
			raid_show_target_opinion_neutral = yes
		}

		# Can prepare
		available = {
			raid_available_grey_zone = yes
		}

		launchable = {
			set_temp_variable = { cost = 99 }
			raid_can_launch = yes
		}

		target_type = {
			building = {
				type = fossil_powerplant
			}
			building = {
				type = renewable_energy_infra
			}
		}

		unit_requirements = {
			battalion_types = {
				drone_tactical_company = { min = 1 }
			}
		}
		# NCE: alternative eligible formation
		unit_requirements = {
			battalion_types = {
				XS_drone_tactical_company = { min = 1 }
			}
		}

		# NCE: alternative eligible formation
		unit_requirements = {
			battalion_types = {
				Team_drone_tactical_company = { min = 1 }
			}
		}

		essential_equipment = {
			medium_plane_suicide_airframe = 500
		}

		target_icon = GFX_other_target_icon
		launch_sound = raid_launch_air

		starting_point = {
			types = { air_base }
		}

		success_factors = {
			success = {
				base = 0.15

				# Raiding unit modifiers
				experience = {
					weight = 0.2
					start_weight = -0.2
					reference = 0.5
				}
				organisation = {
					weight = 0.3
					start_weight = -0.3
					reference = 60
				}
				recon = {
					weight = 0.5
					start_weight = -0.05
					reference = 10
				}
				intel = {
					weight = 0.5
					start_weight = -0.1
					start_reference = 10
					reference = 100
				}

				### Target Modifiers
				anti_air = {
					reference = 5
					weight = -0.25
				}
				radar = {
					reference = 1
					weight = -0.15
				}
				interception = {
					reference = 500
					weight = -0.2
				}
			}

			disaster = {
				base = 0.25
			}

			critical = {
				base = 0.05
			}
		}

		success_levels = {
			failure = {
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -100 }
					apply_raid_failure_losses = yes
				}
				victim_effects = {
					send_raid_event_to_victim = yes
				}
			}

			limited_success = {
				victim_effects = {
					send_raid_event_to_victim = yes

					var:target_state = {
						set_temp_variable = { ROOT.powerplant_tgt = THIS.building_level@fossil_powerplant }
						set_temp_variable = { ROOT.renewable_tgt = THIS.building_level@renewable_energy_infra }
					}

					calculate_aa_defense_value = yes

					#apply power grid disruption modifier
					var:target_state = {
						add_dynamic_modifier = {
							modifier = power_minor_strike_modifier
							days = 150
						}
					}

					#scale damage based on success level
					set_temp_variable = { building_damage_by_missile = 1.0 }

					set_temp_variable = { raid_damage_mult = 25 }
					apply_raid_building_damage_limited = yes

					set_temp_variable = { damage_split = 0 }

					if = {
						limit = {
							check_variable = { powerplant_tgt > 0 }
						}
						add_to_temp_variable = { damage_split = 1 }
					}

					if = {
						limit = {
							check_variable = { renewable_tgt > 0 }
						}
						add_to_temp_variable = { damage_split = 1 }
					}

					if = {
						limit = {
							check_variable = { damage_split > 1 }
						}
						divide_temp_variable = { building_damage_by_missile = damage_split }
					}

					set_temp_variable = { max_clamp = powerplant_tgt }
					add_to_temp_variable = { max_clamp = renewable_tgt }

					clamp_temp_variable = {
						var = building_damage_by_missile
						min = 0
						max = max_clamp
					}

					if = { limit = { check_variable = { building_damage_by_missile < 1 } } set_temp_variable = { building_damage_by_missile = 1.0 } }

					var:target_state = {
						if = { limit = { fossil_powerplant > 0 }
							meta_effect = {
								text = {
									damage_building = {
										type = fossil_powerplant
										damage = [DAM]
									}
								}
								DAM = "[?building_damage_by_missile]"
							}
						}
						if = { limit = { renewable_energy_infra > 0 }
							meta_effect = {
								text = {
									damage_building = {
										type = renewable_energy_infra
										damage = [DAM]
									}
								}
								DAM = "[?building_damage_by_missile]"
							}
						}
					}
				}
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -100 }
					apply_raid_limited_success_losses = yes
				}
			}

			success = {
				victim_effects = {
					send_raid_event_to_victim = yes

					var:target_state = {
						set_temp_variable = { ROOT.powerplant_tgt = THIS.building_level@fossil_powerplant }
						set_temp_variable = { ROOT.renewable_tgt = THIS.building_level@renewable_energy_infra }
					}

					calculate_aa_defense_value = yes

					var:target_state = {
						add_dynamic_modifier = {
							modifier = power_strike_modifier
							days = 200
						}
					}

					set_temp_variable = { building_damage_by_missile = 1.0 }

					set_temp_variable = { raid_damage_mult = 40 }
					apply_raid_building_damage_success = yes

					set_temp_variable = { damage_split = 0 }

					if = {
						limit = {
							check_variable = { powerplant_tgt > 0 }
						}
						add_to_temp_variable = { damage_split = 1 }
					}

					if = {
						limit = {
							check_variable = { renewable_tgt > 0 }
						}
						add_to_temp_variable = { damage_split = 1 }
					}

					if = {
						limit = {
							check_variable = { damage_split > 1 }
						}
						divide_temp_variable = { building_damage_by_missile = damage_split }
					}

					set_temp_variable = { max_clamp = powerplant_tgt }
					add_to_temp_variable = { max_clamp = renewable_tgt }

					clamp_temp_variable = {
						var = building_damage_by_missile
						min = 0
						max = max_clamp
					}

					if = { limit = { check_variable = { building_damage_by_missile < 1 } } set_temp_variable = { building_damage_by_missile = 1.0 } }

					var:target_state = {
						if = { limit = { fossil_powerplant > 0 }
							meta_effect = {
								text = {
									damage_building = {
										type = fossil_powerplant
										damage = [DAM]
									}
								}
								DAM = "[?building_damage_by_missile]"
							}
						}
						if = { limit = { renewable_energy_infra > 0 }
							meta_effect = {
								text = {
									damage_building = {
										type = renewable_energy_infra
										damage = [DAM]
									}
								}
								DAM = "[?building_damage_by_missile]"
							}
						}
					}
				}
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -100 }
					apply_raid_success_losses = yes
				}
			}

			critical_success = {
				victim_effects = {
					send_raid_event_to_victim = yes

					var:target_state = {
						set_temp_variable = { ROOT.powerplant_tgt = THIS.building_level@fossil_powerplant }
						set_temp_variable = { ROOT.renewable_tgt = THIS.building_level@renewable_energy_infra }
					}

					calculate_aa_defense_value = yes

					var:target_state = {
						add_dynamic_modifier = {
							modifier = power_critical_strike_modifier
							days = 270
						}
					}

					var:victim_country = {
						set_country_flag = power_grid_damaged
					}

					set_temp_variable = { building_damage_by_missile = 1.0 }

					set_temp_variable = { raid_damage_mult = 60 }
					apply_raid_building_damage_critical = yes

					set_temp_variable = { damage_split = 0 }

					if = {
						limit = {
							check_variable = { powerplant_tgt > 0 }
						}
						add_to_temp_variable = { damage_split = 1 }
					}

					if = {
						limit = {
							check_variable = { renewable_tgt > 0 }
						}
						add_to_temp_variable = { damage_split = 1 }
					}

					if = {
						limit = {
							check_variable = { damage_split > 1 }
						}
						divide_temp_variable = { building_damage_by_missile = damage_split }
					}

					set_temp_variable = { max_clamp = powerplant_tgt }
					add_to_temp_variable = { max_clamp = renewable_tgt }

					clamp_temp_variable = {
						var = building_damage_by_missile
						min = 0
						max = max_clamp
					}

					if = { limit = { check_variable = { building_damage_by_missile < 1 } } set_temp_variable = { building_damage_by_missile = 1.0 } }

					var:target_state = {
						if = { limit = { fossil_powerplant > 0 }
							meta_effect = {
								text = {
									damage_building = {
										type = fossil_powerplant
										damage = [DAM]
									}
								}
								DAM = "[?building_damage_by_missile]"
							}
						}
						if = { limit = { renewable_energy_infra > 0 }
							meta_effect = {
								text = {
									damage_building = {
										type = renewable_energy_infra
										damage = [DAM]
									}
								}
								DAM = "[?building_damage_by_missile]"
							}
						}
					}
				}
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -100 }
					apply_raid_critical_success_losses = yes
				}
			}
		}

		ai_will_do = {
			base = 0

			modifier = {
				add = 5
				has_war_with = FROM
			}
			modifier = {
				add = 3
				FROM = {
					NOT = { has_idea = nuclear_power }
				}
			}
			modifier = {
				factor = 0
				NOT = { has_war_with = FROM }
				FROM = {
					OR = {
						has_idea = NATO_member
						has_idea = CSTO_member
						has_idea = EU_member
						has_idea = faction_resistance_axis_member
					}
				}
			}
			# Alliance gate — back off when target is in a faction and our alliance ratio is weak (<0.7)
			modifier = {
				factor = 0
				raid_alliance_unfavorable = yes
			}
			# Doctrinal reach gate — isolation/local_security/limited interventionism can't reach.
			# Bypassed by the rule_raid_doctrine_reach game rule.
			modifier = {
				factor = 0
				raid_intervention_doctrine_reach_block = yes
			}
			modifier = {
				has_country_flag = conceded_to@FROM
				factor = 0
			}
			modifier = {
				factor = 0
				is_ally_with = FROM
				raid_skip_target_non_hostile_no_retaliation = yes
			}
			modifier = {
				factor = 0
				OR = {
					FROM = { is_subject_of = ROOT }
					is_subject_of = FROM
				}
			}
			modifier = {
				# Don't raid nations we have influence in
				factor = 0
				NOT = { has_country_flag = promised_retaliation_against@FROM }
				FROM = { is_influencer = yes }
			}
		}
	}

	#Suicide drone strikes against rocket launch sites
	drone_rocket_site_strike = {
		days_to_prepare = 14
		days_re_enable = 120

		category = drone_strike_raids

		command_power = 20
		speed_multiplier = 10

		arrow = {
			type = air
		}

		# Specific Target is visible
		show_target = {
			OR = {
				has_war_with = FROM
				has_wargoal_against = FROM
				is_justifying_wargoal_against = FROM
			}
			FROM = { MD_special_countries = no }
		}

		# Can prepare
		available = {
			drone_raid_available_hostile = yes
		}

		launchable = {
			has_war_with = FROM
		}

		target_type = {
			building = {
				type = rocket_site
			}
		}

		unit_requirements = {
			battalion_types = {
				drone_tactical_company = { min = 1 }
			}
		}
		# NCE: alternative eligible formation
		unit_requirements = {
			battalion_types = {
				XS_drone_tactical_company = { min = 1 }
			}
		}

		# NCE: alternative eligible formation
		unit_requirements = {
			battalion_types = {
				Team_drone_tactical_company = { min = 1 }
			}
		}

		essential_equipment = {
			medium_plane_suicide_airframe = 500
		}

		target_icon = GFX_other_target_icon
		launch_sound = raid_launch_air

		starting_point = {
			types = { air_base }
		}

		success_factors = {
			success = {
				base = 0.15

				# Raiding unit modifiers
				experience = {
					weight = 0.2
					start_weight = -0.2
					reference = 0.5
				}
				organisation = {
					weight = 0.3
					start_weight = -0.3
					reference = 60
				}
				recon = {
					weight = 0.5
					start_weight = -0.05
					reference = 10
				}
				intel = {
					weight = 0.5
					start_weight = -0.1
					start_reference = 10
					reference = 100
				}

				### Target Modifiers
				anti_air = {
					reference = 5
					weight = -0.25
				}
				radar = {
					reference = 1
					weight = -0.15
				}
				interception = {
					reference = 500
					weight = -0.2
				}
			}

			disaster = {
				base = 0.25
			}

			critical = {
				base = 0.05
			}
		}

		success_levels = {
			failure = {
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -300 }
					apply_raid_failure_losses = yes
				}
				victim_effects = {
					send_raid_event_to_victim = yes
				}
			}

			limited_success = {
				victim_effects = {
					send_raid_event_to_victim = yes

					var:target_state = {
						set_temp_variable = { ROOT.rocket_site_tgt = THIS.building_level@rocket_site }
					}

					calculate_aa_defense_value = yes

					set_temp_variable = { building_damage_by_missile = 1.0 }

					set_temp_variable = { raid_damage_mult = 30 }
					apply_raid_building_damage_limited = yes

					clamp_temp_variable = {
						var = building_damage_by_missile
						min = 0
						max = rocket_site_tgt
					}

					if = { limit = { check_variable = { building_damage_by_missile < 1 } } set_temp_variable = { building_damage_by_missile = 1.0 } }

					var:target_state = {
						if = { limit = { rocket_site > 0 }
							meta_effect = {
								text = {
									damage_building = {
										type = rocket_site
										damage = [DAM]
									}
								}
								DAM = "[?building_damage_by_missile]"
							}
						}
					}
				}
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -300 }
					apply_raid_limited_success_losses = yes
				}
			}

			success = {
				victim_effects = {
					send_raid_event_to_victim = yes

					var:target_state = {
						set_temp_variable = { ROOT.rocket_site_tgt = THIS.building_level@rocket_site }
					}

					calculate_aa_defense_value = yes

					set_temp_variable = { building_damage_by_missile = 1.0 }

					set_temp_variable = { raid_damage_mult = 50 }
					apply_raid_building_damage_success = yes

					clamp_temp_variable = {
						var = building_damage_by_missile
						min = 0
						max = rocket_site_tgt
					}

					if = { limit = { check_variable = { building_damage_by_missile < 1 } } set_temp_variable = { building_damage_by_missile = 1.0 } }

					var:target_state = {
						if = { limit = { rocket_site > 0 }
							meta_effect = {
								text = {
									damage_building = {
										type = rocket_site
										damage = [DAM]
									}
								}
								DAM = "[?building_damage_by_missile]"
							}
						}
					}
				}
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -300 }
					apply_raid_success_losses = yes
				}
			}

			critical_success = {
				victim_effects = {
					send_raid_event_to_victim = yes

					var:target_state = {
						set_temp_variable = { ROOT.rocket_site_tgt = THIS.building_level@rocket_site }
					}

					calculate_aa_defense_value = yes

					set_temp_variable = { building_damage_by_missile = 1.0 }

					set_temp_variable = { raid_damage_mult = 70 }
					apply_raid_building_damage_critical = yes

					clamp_temp_variable = {
						var = building_damage_by_missile
						min = 0
						max = rocket_site_tgt
					}

					if = { limit = { check_variable = { building_damage_by_missile < 1 } } set_temp_variable = { building_damage_by_missile = 1.0 } }

					var:target_state = {
						if = { limit = { rocket_site > 0 }
							meta_effect = {
								text = {
									damage_building = {
										type = rocket_site
										damage = [DAM]
									}
								}
								DAM = "[?building_damage_by_missile]"
							}
						}
					}
				}
				actor_effects = {
					set_temp_variable = { raid_pp_loss = -300 }
					apply_raid_critical_success_losses = yes
				}
			}
		}

		ai_will_do = {
			base = 0

			modifier = {
				add = 5
				has_war_with = FROM
			}
			modifier = {
				add = 3
				FROM = {
					has_idea = rocket_tech
				}
			}
			modifier = {
				factor = 0
				NOT = { has_war_with = FROM }
				FROM = {
					OR = {
						has_idea = NATO_member
						has_idea = CSTO_member
						has_idea = EU_member
						has_idea = faction_resistance_axis_member
					}
				}
			}
			# Alliance gate — back off when target is in a faction and our alliance ratio is weak (<0.7)
			modifier = {
				factor = 0
				raid_alliance_unfavorable = yes
			}
			# Doctrinal reach gate — isolation/local_security/limited interventionism can't reach.
			# Bypassed by the rule_raid_doctrine_reach game rule.
			modifier = {
				factor = 0
				raid_intervention_doctrine_reach_block = yes
			}
			modifier = {
				has_country_flag = conceded_to@FROM
				factor = 0
			}
			modifier = {
				factor = 0
				is_ally_with = FROM
				raid_skip_target_non_hostile_no_retaliation = yes
			}
			modifier = {
				factor = 0
				OR = {
					FROM = { is_subject_of = ROOT }
					is_subject_of = FROM
				}
			}
			modifier = {
				# Don't raid nations we have influence in
				factor = 0
				NOT = { has_country_flag = promised_retaliation_against@FROM }
				FROM = { is_influencer = yes }
			}
		}
	}
}
