############################################################################################################
#	Expert AI mod - difficulty triggers
############################################################################################################

EAI_DIFFICULTY_has_difficulty_bonus = {
	OR = {
		# has_dynamic_modifier = { modifier = EAI_difficulty_bonus_modifier }
		# has_dynamic_modifier = { modifier = EAI_dynamic_difficulty_bonus_modifier }
		check_variable = { EAI_difficulty_equipment_bonus_active > 0 }
	}
}

EAI_DIFFICULTY_dynamic_bonus_trigger = {

	NOT = { has_capitulated = yes }

	any_enemy_country = {

		OR = {
			is_ai = no 
			
			any_other_country = { is_ai = no has_war_with = ROOT }
		}
		
		OR = {
			is_neighbor_of = ROOT 

			any_of_scopes = { array = ROOT.owned_states
				is_controlled_by = PREV
			}
			
			any_of_scopes = { array = controlled_states
				
				any_of_scopes = { array = ROOT.controlled_states

					distance_to = { target = PREV value < 800 } 
				} 
			} 
		}
	}
}

###

EAI_DIFFICULTY_ftr_bonus_trigger = {
	set_temp_variable = { tmp = num_of_military_factories }
	multiply_temp_variable = { tmp = 30 }

	OR = {
		has_deployed_air_force_size = { type = fighter size < 400 }

		meta_trigger = {
			text = { has_deployed_air_force_size = { type = fighter size < [x] } }
			x = "[?tmp|.0]"
		}
	}
}

EAI_DIFFICULTY_cas_bonus_trigger = {
	set_temp_variable = { tmp = num_of_military_factories }
	multiply_temp_variable = { tmp = 10 }

	OR = {
		has_deployed_air_force_size = { type = cas size < 400 }

		meta_trigger = {
			text = { has_deployed_air_force_size = { type = cas size < [x] } }
			x = "[?tmp|.0]"
		}
	}
}

EAI_DIFFICULTY_tac_bonus_trigger = {
	set_temp_variable = { tmp = num_of_military_factories }
	multiply_temp_variable = { tmp = 10 }

	OR = {
		has_deployed_air_force_size = { type = tactical_bomber size < 400 }

		meta_trigger = {
			text = { has_deployed_air_force_size = { type = tactical_bomber size < [x] } }
			x = "[?tmp|.0]"
		}
	}
}

EAI_DIFFICULTY_str_bonus_trigger = {
	set_temp_variable = { tmp = num_of_military_factories }
	multiply_temp_variable = { tmp = 10 }

	OR = {
		has_deployed_air_force_size = { type = strategic_bomber size < 400 }

		meta_trigger = {
			text = { has_deployed_air_force_size = { type = strategic_bomber size < [x] } }
			x = "[?tmp|.0]"
		}
	}
}

###

EAI_DIFFICULTY_small_plane_airframe_BONUS_TRIGGER = {

	set_temp_variable = { tmp = num_of_military_factories }
	multiply_temp_variable = { tmp = 15 }
	clamp_temp_variable = { var = tmp min = 0 max = 1000 }

	OR = {
		has_deployed_air_force_size = { type = fighter size < 400 }

		meta_trigger = {
			text = { has_deployed_air_force_size = { type = fighter size < [x] } }
			x = "[?tmp|.0]"
		}
	}
}
EAI_DIFFICULTY_cv_small_plane_airframe_BONUS_TRIGGER = {

	always = no
}
EAI_DIFFICULTY_medium_plane_airframe_BONUS_TRIGGER = {

	set_temp_variable = { tmp = num_of_military_factories }
	multiply_temp_variable = { tmp = 10 }
	clamp_temp_variable = { var = tmp min = 0 max = 500 }

	OR = {
		has_deployed_air_force_size = { type = tactical_bomber size < 400 }

		meta_trigger = {
			text = { has_deployed_air_force_size = { type = tactical_bomber size < [x] } }
			x = "[?tmp|.0]"
		}
	}
}
EAI_DIFFICULTY_large_plane_airframe_BONUS_TRIGGER = {

	set_temp_variable = { tmp = num_of_military_factories }
	multiply_temp_variable = { tmp = 5 }
	clamp_temp_variable = { var = tmp min = 0 max = 500 }

	OR = {
		has_deployed_air_force_size = { type = strategic_bomber size < 400 }

		meta_trigger = {
			text = { has_deployed_air_force_size = { type = strategic_bomber size < [x] } }
			x = "[?tmp|.0]"
		}
	}
}
EAI_DIFFICULTY_transport_plane_equipment_BONUS_TRIGGER = {

	set_temp_variable = { tmp = num_of_military_factories }
	multiply_temp_variable = { tmp = 1 }
	clamp_temp_variable = { var = tmp min = 0 max = 100 }

	OR = {
		has_deployed_air_force_size = { type = air_transport size < 100 }

		meta_trigger = {
			text = { has_deployed_air_force_size = { type = air_transport size < [x] } }
			x = "[?tmp|.0]"
		}
	}
}
EAI_DIFFICULTY_small_plane_cas_airframe_BONUS_TRIGGER = {

	set_temp_variable = { tmp = num_of_military_factories }
	multiply_temp_variable = { tmp = 10 }
	clamp_temp_variable = { var = tmp min = 0 max = 500 }

	OR = {
		has_deployed_air_force_size = { type = cas size < 400 }

		meta_trigger = {
			text = { has_deployed_air_force_size = { type = cas size < [x] } }
			x = "[?tmp|.0]"
		}
	}
}
EAI_DIFFICULTY_cv_small_plane_cas_airframe_BONUS_TRIGGER = {

	always = no
}
EAI_DIFFICULTY_small_plane_naval_bomber_airframe_BONUS_TRIGGER = {

	set_temp_variable = { tmp = num_of_military_factories }
	multiply_temp_variable = { tmp = 5 }
	clamp_temp_variable = { var = tmp min = 0 max = 500 }

	OR = {
		has_deployed_air_force_size = { type = naval_bomber size < 400 }

		meta_trigger = {
			text = { has_deployed_air_force_size = { type = naval_bomber size < [x] } }
			x = "[?tmp|.0]"
		}
	}
}
EAI_DIFFICULTY_cv_small_plane_naval_bomber_airframe_BONUS_TRIGGER = {

	always = no
}
EAI_DIFFICULTY_small_plane_suicide_airframe_BONUS_TRIGGER = {

	always = no
}
EAI_DIFFICULTY_cv_small_plane_suicide_airframe_BONUS_TRIGGER = {

	always = no
}
EAI_DIFFICULTY_medium_plane_fighter_airframe_BONUS_TRIGGER = {

	set_temp_variable = { tmp = num_of_military_factories }
	multiply_temp_variable = { tmp = 15 }
	clamp_temp_variable = { var = tmp min = 0 max = 1000 }

	OR = {
		has_deployed_air_force_size = { type = heavy_fighter size < 400 }

		meta_trigger = {
			text = { has_deployed_air_force_size = { type = heavy_fighter size < [x] } }
			x = "[?tmp|.0]"
		}
	}
}
EAI_DIFFICULTY_medium_plane_scout_plane_airframe_BONUS_TRIGGER = {

	set_temp_variable = { tmp = num_of_military_factories }
	multiply_temp_variable = { tmp = 1 }
	clamp_temp_variable = { var = tmp min = 0 max = 100 }

	OR = {
		has_deployed_air_force_size = { type = scout_plane size < 100 }

		meta_trigger = {
			text = { has_deployed_air_force_size = { type = figscout_planehter size < [x] } }
			x = "[?tmp|.0]"
		}
	}
}
EAI_DIFFICULTY_large_plane_maritime_patrol_plane_airframe_BONUS_TRIGGER = {

	set_temp_variable = { tmp = num_of_military_factories }
	multiply_temp_variable = { tmp = 1 }
	clamp_temp_variable = { var = tmp min = 0 max = 200 }

	OR = {
		has_deployed_air_force_size = { type = maritime_patrol_plane size < 100 }

		meta_trigger = {
			text = { has_deployed_air_force_size = { type = maritime_patrol_plane size < [x] } }
			x = "[?tmp|.0]"
		}
	}
}