# Written by Hiddengearz

# air_factory_balance
# alliance
# antagonize
# area_priority
# befriend
# unit_ratio
# build_building
# build_ship
# conquer
# contain
# equipment_production_factor
# equipment_stockpile
# garrison
# ignore
# influence
# invade
# pp_spend_priority
# protect
# research_tech
# role_ratio
# send_volunteers_desire
# support
# template_prio
# template_xp_reserve 
# build_army

###MD4 Generic Land Unit production###
MD4_minor_Land_unit_prod = { #mil 0 - 10
	enable = {
		num_of_military_factories < 11 #10 or less
		
	}
	
	abort = {
		
		or = {
			num_of_military_factories > 10 #11 or greater
			# is_major = yes
		}
		
	}
	
	ai_strategy = {
		type = role_ratio
		id = Militia
		value = 60
	}
	ai_strategy = {
		type = role_ratio
		id = L_Inf
		value = 20
	}
	ai_strategy = {
		type = role_ratio
		id = infantry
		value = 10
	}
	ai_strategy = {
		type = role_ratio
		id = garrison
		value = 10
	}
	ai_strategy = {
		type = role_ratio
		id = mechanized
		value = 0
	}
	ai_strategy = {
		type = role_ratio
		id = armor
		value = 0
	}
	ai_strategy = {
		type = role_ratio
		id = marines
		value = 0
	}
	ai_strategy = {
		type = role_ratio
		id = Air_assault
		value = 0
	}
	ai_strategy = {
		type = role_ratio
		id = Air_Inf
		value = 0
	}
	ai_strategy = {
		type = role_ratio
		id = Special_Forces
		value = 0
	}
	
}
MD4_Low_Secondary_Land_unit_prod = { #Mil 11 - 20
	enable = {
		num_of_military_factories > 10 #11 or greater
		num_of_military_factories < 21 #20 or less
		# is_major = no
			
	}
	
	abort = {
		or = {
			num_of_military_factories > 20 #21 or greater
			num_of_military_factories < 11 #10 or less
			##is_major = yes
		}
	}

	#infantry
	
	ai_strategy = {
		type = role_ratio
		id = infantry
		value = 50
	}
	ai_strategy = {
		type = role_ratio
		id = mechanized
		value = 20
	}
	ai_strategy = {
		type = role_ratio
		id = L_Inf
		value = 15
	}
	ai_strategy = {
		type = role_ratio
		id = armor
		value = 5
	}
	ai_strategy = {
		type = role_ratio
		id = garrison
		value = 5
	}
	ai_strategy = {
		type = role_ratio
		id = marines
		value = 5
	}
	ai_strategy = {
		type = role_ratio
		id = Air_assault
		value = 0
	}
	ai_strategy = {
		type = role_ratio
		id = Air_Inf
		value = 0
	}
	ai_strategy = {
		type = role_ratio
		id = Special_Forces
		value = 0
	}
	
	
	
}
MD4_High_Secondary_Land_unit_prod = { #mil 21 - 35
	enable = {
		
		num_of_military_factories > 20 #21 or greater
		num_of_military_factories < 36 #35 or less
		# is_major = no
	}
	
	abort = {
		
		or = {
			num_of_military_factories > 35 #36 or more
			num_of_military_factories < 21 #20 or less
			# is_major = yes
		}
	}

	#infantry
	
	
	ai_strategy = {
		type = role_ratio
		id = mechanized
		value = 35
	}
	ai_strategy = {
		type = role_ratio
		id = infantry
		value = 20
	}
	ai_strategy = {
		type = role_ratio
		id = armor
		value = 10
	}
	ai_strategy = {
		type = role_ratio
		id = garrison
		value = 5
	}
	ai_strategy = {
		type = role_ratio
		id = L_Inf
		value = 5
	}
	ai_strategy = {
		type = role_ratio
		id = marines
		value = 5
	}
	ai_strategy = {
		type = role_ratio
		id = Air_assault
		value = 5
	}
	ai_strategy = {
		type = role_ratio
		id = Special_Forces
		value = 5
	}
	ai_strategy = {
		type = role_ratio
		id = Air_Inf
		value = 0
	}
	
	
	
	
}
MD4_Major_Land_unit_prod = { #Mil 36+
	enable = {
		
		num_of_military_factories > 35 #36 or greater
		# is_major = yes
	}
	
	abort = {
	
		#or = {
			num_of_military_factories < 35 #36 or less
			# is_major = no
		# }
	}

	#infantry
	
	ai_strategy = {
		type = role_ratio
		id = mechanized
		value = 40
	}
	ai_strategy = {
		type = role_ratio
		id = infantry
		value = 20
	}
	ai_strategy = {
		type = role_ratio
		id = armor
		value = 10
	}
	ai_strategy = {
		type = role_ratio
		id = garrison
		value = 5
	}
	ai_strategy = {
		type = role_ratio
		id = L_Inf
		value = 5
	}
	ai_strategy = {
		type = role_ratio
		id = marines
		value = 5
	}
	ai_strategy = {
		type = role_ratio
		id = Air_assault
		value = 5
	}
	ai_strategy = {
		type = role_ratio
		id = Air_Inf
		value = 5
	}
	ai_strategy = {
		type = role_ratio
		id = Special_Forces
		value = 5
	}
	
	
	
	
}

###MD4 Generic Naval Unit production###
MD4_minor_Naval_unit_prod = { #Screen's only | mil 0 - 10
	enable = {
		num_of_military_factories < 11 #10 or less
		
	}
	
	abort = {
		
		or = {
			num_of_military_factories > 10 #11 or greater
			# is_major = yes
		}
		
	}
	#carrier
	ai_strategy = {
		type = unit_ratio
		id = carrier
		value = 0
	}
	ai_strategy = {
		type = equipment_production_factor
		id = carrier
		value = 0
	}
	
	#capital_ship
	ai_strategy = {
		type = unit_ratio
		id = capital_ship
		value = 0
	}
	ai_strategy = {
		type = equipment_production_factor
		id = capital_ship
		value = 0
	}
	
	#submarine
	ai_strategy = {
		type = unit_ratio
		id = submarine
		value = 0
	}
	ai_strategy = {
		type = equipment_production_factor
		id = submarine
		value = 0
	}
	
	#screen_ship
	ai_strategy = {
		type = unit_ratio
		id = screen_ship
		value = 70
	}
	ai_strategy = {
		type = equipment_production_factor
		id = screen_ship
		value = 70
	}
	
	#convoy
	ai_strategy = {
		type = unit_ratio
		id = convoy
		value = 30
	}
	ai_strategy = {
		type = equipment_production_factor
		id = convoy
		value = 30
	}
	
	
}
MD4_Low_Secondary_Naval_unit_prod = { #Screen's/subs | Mil 11 - 20
	enable = {
		num_of_military_factories > 10 #11 or greater
		num_of_military_factories < 21 #20 or less
		# is_major = no
			
	}
	
	abort = {
		or = {
			num_of_military_factories > 20 #21 or greater
			num_of_military_factories < 11 #10 or less
			##is_major = yes
		}
	}
	#carrier
	ai_strategy = {
		type = unit_ratio
		id = carrier
		value = 0
	}
	ai_strategy = {
		type = equipment_production_factor
		id = carrier
		value = 0
	}
	
	#capital_ship
	ai_strategy = {
		type = unit_ratio
		id = capital_ship
		value = 0
	}
	ai_strategy = {
		type = equipment_production_factor
		id = capital_ship
		value = 0
	}
	
	#submarine
	ai_strategy = {
		type = unit_ratio
		id = submarine
		value = 20
	}
	ai_strategy = {
		type = equipment_production_factor
		id = submarine
		value = 20
	}
	
	#screen_ship
	ai_strategy = {
		type = unit_ratio
		id = screen_ship
		value = 50
	}
	ai_strategy = {
		type = equipment_production_factor
		id = screen_ship
		value = 50
	}
	
	#convoy
	ai_strategy = {
		type = unit_ratio
		id = convoy
		value = 30
	}
	ai_strategy = {
		type = equipment_production_factor
		id = convoy
		value = 30
	}
	
	
}

AI_make_more_guns = {
	enable = {
		always = yes
	}
	
	ai_strategy = {
		type = equipment_production_factor
		id = infantry
		value = 100
	}
}
MD4_High_Secondary_Naval_unit_prod = { #carrier/capital/Screen's/subs | mil 21 - 35
	enable = {
		
		num_of_military_factories > 20 #21 or greater
		num_of_military_factories < 36 #35 or less
		# is_major = no
	}
	
	abort = {
		
		or = {
			num_of_military_factories > 35 #36 or more
			num_of_military_factories < 21 #20 or less
			# is_major = yes
		}
	}
	
	#carrier
	ai_strategy = {
		type = unit_ratio
		id = carrier
		value = 5
	}
	ai_strategy = {
		type = equipment_production_factor
		id = carrier
		value = 5
	}
	
	#capital_ship
	ai_strategy = {
		type = unit_ratio
		id = capital_ship
		value = 20
	}
	ai_strategy = {
		type = equipment_production_factor
		id = capital_ship
		value = 20
	}
	
	#submarine
	ai_strategy = {
		type = unit_ratio
		id = submarine
		value = 15
	}
	ai_strategy = {
		type = equipment_production_factor
		id = submarine
		value = 15
	}
	
	#screen_ship
	ai_strategy = {
		type = unit_ratio
		id = screen_ship
		value = 30
	}
	ai_strategy = {
		type = equipment_production_factor
		id = screen_ship
		value = 30
	}
	
	#convoy
	ai_strategy = {
		type = unit_ratio
		id = convoy
		value = 30
	}
	ai_strategy = {
		type = equipment_production_factor
		id = convoy
		value = 30
	}
	
	
}
MD4_Major_Naval_unit_prod = { #carrier/capital/Screen's/subs | Mil 36+
	enable = {
		
		num_of_military_factories > 35 #36 or greater
		# is_major = yes
	}
	
	abort = {
	
		#or = {
			num_of_military_factories < 35 #36 or less
			# is_major = no
		# }
	}
	
	#carrier
	ai_strategy = {
		type = unit_ratio
		id = carrier
		value = 20
	}
	ai_strategy = {
		type = equipment_production_factor
		id = carrier
		value = 20
	}
	
	#capital_ship
	ai_strategy = {
		type = unit_ratio
		id = capital_ship
		value = 10
	}
	ai_strategy = {
		type = equipment_production_factor
		id = capital_ship
		value = 10
	}
	
	#submarine
	ai_strategy = {
		type = unit_ratio
		id = submarine
		value = 15
	}
	ai_strategy = {
		type = equipment_production_factor
		id = submarine
		value = 15
	}
	
	#screen_ship
	ai_strategy = {
		type = unit_ratio
		id = screen_ship
		value = 30
	}
	ai_strategy = {
		type = equipment_production_factor
		id = screen_ship
		value = 30
	}
	
	#convoy
	ai_strategy = {
		type = unit_ratio
		id = convoy
		value = 25
	}
	ai_strategy = {
		type = equipment_production_factor
		id = convoy
		value = 25
	}
	
	
}

###MD4 Generic Air Unit production###
MD4_minor_Air_unit_prod = { #Screen's only | mil 0 - 10
	enable = {
		num_of_military_factories < 11 #10 or less
		
	}
	
	abort = {
		
		or = {
			num_of_military_factories > 10 #11 or greater
			# is_major = yes
		}
		
	}
	
	######################
	###Air unit factors###
	######################
	
	#Fighter
	ai_strategy = {
		type = unit_ratio
		id = fighter
		value = 50
	}
	ai_strategy = {
		type = equipment_production_factor
		id = fighter
		value = 50
	}
	
	#Cas
	ai_strategy = {
		type = unit_ratio
		id = cas
		value = 50
	}
	ai_strategy = {
		type = equipment_production_factor
		id = cas
		value = 50
	}
	
	#Tactical Bomber
	ai_strategy = {
		type = unit_ratio
		id = tactical_bomber
		value = 0
	}
	ai_strategy = {
		type = equipment_production_factor
		id = tactical_bomber
		value = 0
	}
	
	#strategic_bomber
	ai_strategy = {
		type = unit_ratio
		id = strategic_bomber
		value = 0
	}
	ai_strategy = {
		type = equipment_production_factor
		id = strategic_bomber
		value = 0
	}
	
	#naval_bomber
	ai_strategy = {
		type = unit_ratio
		id = naval_bomber
		value = 0
	}
	ai_strategy = {
		type = equipment_production_factor
		id = naval_bomber
		value = 0
	}
	
}
MD4_Low_Secondary_Air_unit_prod = { #Screen's/subs | Mil 11 - 20
	enable = {
		num_of_military_factories > 10 #11 or greater
		num_of_military_factories < 21 #20 or less
		# is_major = no
			
	}
	
	abort = {
		or = {
			num_of_military_factories > 20 #21 or greater
			num_of_military_factories < 11 #10 or less
			##is_major = yes
		}
	}
	
	#Fighter
	ai_strategy = {
		type = unit_ratio
		id = fighter
		value = 50
	}
	ai_strategy = {
		type = equipment_production_factor
		id = fighter
		value = 50
	}
	
	#Cas
	ai_strategy = {
		type = unit_ratio
		id = cas
		value = 50
	}
	ai_strategy = {
		type = equipment_production_factor
		id = cas
		value = 50
	}
	
	#Tactical Bomber
	ai_strategy = {
		type = unit_ratio
		id = tactical_bomber
		value = 0
	}
	ai_strategy = {
		type = equipment_production_factor
		id = tactical_bomber
		value = 0
	}
	
	#strategic_bomber
	ai_strategy = {
		type = unit_ratio
		id = strategic_bomber
		value = 0
	}
	ai_strategy = {
		type = equipment_production_factor
		id = strategic_bomber
		value = 0
	}
	
	#naval_bomber
	ai_strategy = {
		type = unit_ratio
		id = naval_bomber
		value = 0
	}
	ai_strategy = {
		type = equipment_production_factor
		id = naval_bomber
		value = 0
	}
	
}
MD4_High_Secondary_Air_unit_prod = { #carrier/capital/Screen's/subs | mil 21 - 35
	enable = {
		
		num_of_military_factories > 20 #21 or greater
		num_of_military_factories < 36 #35 or less
		# is_major = no
	}
	
	abort = {
		
		or = {
			num_of_military_factories > 35 #36 or more
			num_of_military_factories < 21 #20 or less
			# is_major = yes
		}
	}
	
	#Fighter
	ai_strategy = {
		type = unit_ratio
		id = fighter
		value = 50
	}
	ai_strategy = {
		type = equipment_production_factor
		id = fighter
		value = 50
	}
	
	#Cas
	ai_strategy = {
		type = unit_ratio
		id = cas
		value = 50
	}
	ai_strategy = {
		type = equipment_production_factor
		id = cas
		value = 50
	}
	
	#Tactical Bomber
	ai_strategy = {
		type = unit_ratio
		id = tactical_bomber
		value = 0
	}
	ai_strategy = {
		type = equipment_production_factor
		id = tactical_bomber
		value = 0
	}
	
	#strategic_bomber
	ai_strategy = {
		type = unit_ratio
		id = strategic_bomber
		value = 0
	}
	ai_strategy = {
		type = equipment_production_factor
		id = strategic_bomber
		value = 0
	}
	
	#naval_bomber
	ai_strategy = {
		type = unit_ratio
		id = naval_bomber
		value = 0
	}
	ai_strategy = {
		type = equipment_production_factor
		id = naval_bomber
		value = 0
	}
	
}
MD4_Major_Air_unit_prod = { #carrier/capital/Screen's/subs | Mil 36+
	enable = {
		
		num_of_military_factories > 35 #36 or greater
		# is_major = yes
	}
	
	abort = {
	
		#or = {
			num_of_military_factories < 35 #36 or less
			# is_major = no
		# }
	}
	
	#Fighter
	ai_strategy = {
		type = unit_ratio
		id = fighter
		value = 40
	}
	ai_strategy = {
		type = equipment_production_factor
		id = fighter
		value = 40
	}
	
	#Cas
	ai_strategy = {
		type = unit_ratio
		id = cas
		value = 40
	}
	ai_strategy = {
		type = equipment_production_factor
		id = cas
		value = 40
	}
	
	#Tactical Bomber
	ai_strategy = {
		type = unit_ratio
		id = tactical_bomber
		value = 0
	}
	ai_strategy = {
		type = equipment_production_factor
		id = tactical_bomber
		value = 0
	}
	
	#strategic_bomber
	ai_strategy = {
		type = unit_ratio
		id = strategic_bomber
		value = 10
	}
	ai_strategy = {
		type = equipment_production_factor
		id = strategic_bomber
		value = 10
	}
	
	#naval_bomber
	ai_strategy = {
		type = unit_ratio
		id = naval_bomber
		value = 10
	}
	ai_strategy = {
		type = equipment_production_factor
		id = naval_bomber
		value = 10
	}
	
}

default_area_priority = {
	enable = {
	}

	ai_strategy = {
		type = area_priority
		id = europe
		value = 100
	}
	
	ai_strategy = {
		type = area_priority
		id = north_america
		value = 100
	}
	
	ai_strategy = {
		type = area_priority
		id = south_america
		value = 50
	}
	
	ai_strategy = {
		type = area_priority
		id = asia
		value = 75
	}
	
	ai_strategy = {
		type = area_priority
		id = middle_east
		value = 50
	}
	
	ai_strategy = {
		type = area_priority
		id = africa
		value = -90
	}
	
	ai_strategy = {
		type = area_priority
		id = pacific
		value = 300
	}
	
	ai_strategy = {
		type = area_priority
		id = oceania
		value = 80
	}

}

###########################################
####Telling the AI to protect themselves###
###########################################
continent_focus_europe = {
	enable = {
		any_neighbor_country = {
			has_war_with = ROOT
		}
		
		capital_scope = {
			is_on_continent = europe
		}
	}
	
	abort = {
		all_enemy_country = {
			NOT = {
				is_neighbor_of = ROOT
			}
		}
	}
	
	ai_strategy = {
		type = area_priority
		id = europe
		value = 300
	}
}

continent_focus_north_america = {
	enable = {
		any_neighbor_country = {
			has_war_with = ROOT
		}
		
		capital_scope = {
			is_on_continent = north_america
		}
	}
	
	abort = {
		all_enemy_country = {
			NOT = {
				is_neighbor_of = ROOT
			}
		}
	}
	
	ai_strategy = {
		type = area_priority
		id = north_america
		value = 300
	}
}

continent_focus_south_america = {
	enable = {
		any_neighbor_country = {
			has_war_with = ROOT
		}
		
		capital_scope = {
			is_on_continent = south_america
		}
	}
	
	abort = {
		all_enemy_country = {
			NOT = {
				is_neighbor_of = ROOT
			}
		}
	}
	
	ai_strategy = {
		type = area_priority
		id = south_america
		value = 300
	}
}

continent_focus_asia = {
	enable = {
		any_neighbor_country = {
			has_war_with = ROOT
		}
		
		capital_scope = {
			is_on_continent = asia
		}
	}
	
	abort = {
		all_enemy_country = {
			NOT = {
				is_neighbor_of = ROOT
			}
		}
	}
	
	ai_strategy = {
		type = area_priority
		id = asia
		value = 300
	}
}

continent_focus_ME = {
	enable = {
		any_neighbor_country = {
			has_war_with = ROOT
		}
		
		capital_scope = {
			is_on_continent = middle_east
		}
	}
	
	abort = {
		all_enemy_country = {
			NOT = {
				is_neighbor_of = ROOT
			}
		}
	}
	
	ai_strategy = {
		type = area_priority
		id = africa
		value = 300
	}
}

continent_focus_africa = {
	enable = {
		any_neighbor_country = {
			has_war_with = ROOT
		}
		
		capital_scope = {
			is_on_continent = africa
		}
	}
	
	abort = {
		all_enemy_country = {
			NOT = {
				is_neighbor_of = ROOT
			}
		}
	}
	
	ai_strategy = {
		type = area_priority
		id = africa
		value = 300
	}
}
#you know, if micronesia becomes a superpower :P
continent_focus_pacific = {
	enable = {
		any_neighbor_country = {
			has_war_with = ROOT
		}
		
		capital_scope = {
			is_on_continent = pacific
		}
	}
	
	abort = {
		all_enemy_country = {
			NOT = {
				is_neighbor_of = ROOT
			}
		}
	}
	
	ai_strategy = {
		type = area_priority
		id = pacific
		value = 300
	}
}

continent_focus_oceania = {
	enable = {
		any_neighbor_country = {
			has_war_with = ROOT
		}
		
		capital_scope = {
			is_on_continent = oceania
		}
	}
	
	abort = {
		all_enemy_country = {
			NOT = {
				is_neighbor_of = ROOT
			}
		}
	}
	
	ai_strategy = {
		type = area_priority
		id = oceania
		value = 300
	}
}


# default_stockpile_management = {
	# enable = {
		# num_divisions > 150
	# }

	# abort = {
		# num_divisions < 130
	# }

	# ai_strategy = {
		# type = equipment_stockpile
		# value = 35 # double base stockpile #from 25 to 35
	# }
# }

save_admiral_pp_for_later = {
	enable = {
		has_war = no
		threat < 0.3
		has_political_power < 200		
	}
	abort = {
		OR = {
			has_war = yes	
			threat > 0.3
			has_political_power > 200
		}
	}

	ai_strategy = { # dont burn PP on admirals (can still get free ones)
		type = pp_spend_priority
		id = admiral
		value = -100
	}
}

default_pp_spend_amount = {
	enable = {
		always = yes
	}
	
	ai_strategy = {
		type = pp_spend_amount
		id = idea
		value = 100
	}
	
	ai_strategy = {
		type = pp_spend_amount
		id = decision
		value = 100
	}
}

do_not_waste_pp_if_saving_for_manpower_laws = {

	enable = {
		manpower_per_military_factory < 5000
		has_war = yes
		
	}
	abort = {
		OR = {
			manpower_per_military_factory > 500
			has_war = no
		}
	}

	ai_strategy = {
		type = pp_spend_priority
		id = relation
		value = -9999
	}

	ai_strategy = {
		type = pp_spend_priority
		id = guarantee
		value = -9999
	}
}


DEFAULT_template_design = {
	enable = {
		always = yes
	}
	
	ai_strategy = {
		type = template_prio
		id = L_Inf
		value = 10
	}
	ai_strategy = {
		type = template_prio
		id = Militia
		value = 10
	}
	ai_strategy = {
		type = template_prio
		id = infantry
		value = 10
	}
	ai_strategy = {
		type = template_prio
		id = garrison
		value = 10
	}
	ai_strategy = {
		type = template_prio
		id = mechanized
		value = 10
	}
	ai_strategy = {
		type = template_prio
		id = armor
		value = 10
	}
	ai_strategy = {
		type = template_prio
		id = marines
		value = 10
	}
	ai_strategy = {
		type = template_prio
		id = Air_assault
		value = 10
	}
	ai_strategy = {
		type = template_prio
		id = Air_Inf
		value = 10
	}
	ai_strategy = {
		type = template_prio
		id = Special_Forces
		value = 10
	}
	
}