# Written by Henrik "Groogy" Hansson
# Modified by Daniel "Da9L" Sjöberg

# befriend
# conquer
# antagonize
# build_ship
# build army (but with an underscore between)
# unit_ratio
# build_building
# research_tech
# garrison
# protect
# influence
# contain
# area_priority

default_unit_production = {
	enable = {
		always = yes
		# NOT = { original_tag = GER } 
		# NOT = { original_tag = FRA } 
		# NOT = { original_tag = QNG  } 
		# NOT = { original_tag = ENG  }
		# not = { original_tag = CZE } 
		# Not = {
			# OR = {
				# original_tag = JAP
			# }
		# }
	}

	abort = { always = no }
	
	# ai_strategy = {
	# 	type = role_ratio
	# 	id = paratroopers
	# 	value = 0
	# }

	# ai_strategy = {
	# 	type = role_ratio
	# 	id = mountaineers
	# 	value = 4
	# }

	# ai_strategy = {
	# 	type = role_ratio
	# 	id = marines
	# 	value = 0
	# }

	# ai_strategy = {
	# 	type = role_ratio
	# 	id = armor
	# 	value = 2
	# }
	
	# ai_strategy = {
	# 	type = role_ratio
	# 	id = infantry
	# 	value = 80
	# }
	
	# ai_strategy = {
	# 	type = role_ratio
	# 	id = light_infantry
	# 	value = 40
	# }

	# ai_strategy = {
	# 	type = role_ratio
	# 	id = line_infantry
	# 	value = 60
	# }
	
	#Air unit factors
	ai_strategy = {
		type = unit_ratio
		id = fighter
		value = 80
	}
	
	ai_strategy = {
		type = unit_ratio
		id = cas
		value = 5
	}
	
	ai_strategy = {
		type = unit_ratio
		id = tactical_bomber
		value = 5
	}
	
	ai_strategy = {
		type = unit_ratio
		id = strategic_bomber
		value = 5
	}
	
	ai_strategy = {
		type = unit_ratio
		id = naval_bomber
		value = 5
	}
	
	
	# Naval unit factors
	ai_strategy = {
		type = unit_ratio
		id = capital_ship
		value = 10
	}

	ai_strategy = {
		type = unit_ratio
		id = submarine
		value = 10
	}

	ai_strategy = {
		type = unit_ratio
		id = screen_ship
		value = 40
	}

	ai_strategy = {
		type = unit_ratio
		id = convoy
		value = 15
	}
	
	ai_strategy = {
		type = equipment_production_factor
		id = fighter
		value = 35
	}
	
	ai_strategy = {
		type = equipment_production_factor
		id = infantry
		value = 40
	}
	
	ai_strategy = {
		type = equipment_production_factor
		id = artillery
		value = 25
	}
}

default_role_ratios = {
	enable = {
		not = {
			has_dlc = "Man the Guns"
		}
	}

	abort = { always = no }

	ai_strategy = {
		type = role_ratio
		id = naval_capital
		value = 100
	}

	ai_strategy = {
		type = role_ratio
		id = naval_carrier
		value = 100
	}

	ai_strategy = {
		type = role_ratio
		id = naval_sub
		value = 100
	}

	ai_strategy = {
		type = role_ratio
		id = naval_screen
		value = 100
	}
}

default_role_ratios = {
	enable = {
		not = {
			OR = {
				original_tag = PRS
				original_tag = ENG
				original_tag = USA
				original_tag = JAP
				original_tag = SOV
			}
		}
	}

	abort = { always = no }

	ai_strategy = {
		type = role_ratio
		id = naval_capital_bb
		value = -80
	}

	ai_strategy = {
		type = role_ratio
		id = naval_capital_bc
		value = -20
	}

	ai_strategy = {
		type = role_ratio
		id = naval_carrier
		value = -70
	}

	ai_strategy = {
		type = role_ratio
		id = naval_submarine
		value = 100
	}

	ai_strategy = {
		type = role_ratio
		id = naval_screen
		value = 100
	}

	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_light
		value = 20
	}

	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_heavy
		value = 25
	}

	ai_strategy = {
		type = role_ratio
		id = naval_mine_sweeper
		value = 15
	}

	ai_strategy = {
		type = role_ratio
		id = naval_mine_layer
		value = 20
	}
}

#dont_build_capitals_if_on_treaty = {
#	enable = {
#		has_naval_treaty_trigger = yes
#	}
#
#	abort = {
#		not = { has_naval_treaty_trigger = yes }
#	}
#
#	ai_strategy = {
#		type = unit_ratio
#		id = capital_ship
#		value = -2		 #1 to 2
#	}
#	ai_strategy = {
#		type = role_ratio
#		id = naval_capital_bb
#		value = -100
#	}
#
#	ai_strategy = {
#		type = role_ratio
#		id = naval_capital_bc
#		value = -100
#	}
#}

default_garrison_production = {
	enable = {
		NOT = { 
			original_tag = PRS 
			original_tag = RUS
			original_tag = USA
			original_tag = QNG
			original_tag = FRA
			original_tag = JAP
		}
		ai_wants_divisions >  12 #Massively decreasing the amount of garrison and suppression the AI wants
		is_major = yes
	}
	abort = {
		ai_wants_divisions < 13 #Massively decreasing the amount of garrison and suppression the AI wants
		is_major = no
	}

	ai_strategy = {
		type = role_ratio
		id = garrison
		value = 5
	}
	
	ai_strategy = {
		type = role_ratio
		id = suppression
		value = 2
	}
}

default_mountaineers_production = {
	enable = {
		NOT = { original_tag = PRS }
		ai_wants_divisions > 11 #Decreasing the amount of mountaineers the AI wants
	}
	abort = {
		ai_wants_divisions < 12 #Decreasing the amount of mountaineers the AI wants
	}

	ai_strategy = {
		type = role_ratio
		id = mountaineers
		value = 3
	}
}

default_marines_production = {
	enable = {
		NOT = { original_tag = PRS }
		ai_wants_divisions > 49
	}
	abort = {
		ai_wants_divisions < 50
	}

	ai_strategy = {
		type = role_ratio
		id = marines
		value = 0
	}

	ai_strategy = {
		type = role_ratio
		id = infantry
		value = 0
	}
}

default_mobile_production = {
	enable = {
		NOT = { original_tag = PRS }
		ai_wants_divisions > 11
		has_tech = motorised_infantry
	}
	abort = {
		ai_wants_divisions < 12
	}

	ai_strategy = {
		type = role_ratio
		id = mobile
		value = 2
	}
}

default_armored_production = {
	enable = {
		NOT = { original_tag = PRS }
		not = { original_tag = CZE }
		ai_wants_divisions > 49
	}
	abort = {
		ai_wants_divisions < 50
	}

	ai_strategy = {
		type = role_ratio
		id = armor
		value = 2
	}

	ai_strategy = {
		type = role_ratio
		id = infantry
		value = 0
	}
}

slightly_naval_focused_nation = {
	enable = {
		OR = {
			tag = JAP
			tag = USA
			tag = ENG
			tag = FRA
			tag = PIE
		}
	}

	abort = { always = no }

	ai_strategy = {
		type = unit_ratio
		id = capital_ship
		value = 1
	}

	ai_strategy = {
		type = unit_ratio
		id = submarine
		value = 1
	}

	ai_strategy = {
		type = unit_ratio
		id = screen_ship
		value = 1
	}

	ai_strategy = {
		type = unit_ratio
		id = convoy
		value = 1
	}
}

more_naval_focused_nation = {
	enable = {
		OR = {
			tag = JAP
			tag = USA
			tag = ENG
		}
		date > "1941.1.1" #Delaying it by a couple of years
	}

	abort = { always = no }

	ai_strategy = {
		type = unit_ratio
		id = capital_ship
		value = 2		 #1 to 2
	}

	ai_strategy = {
		type = unit_ratio
		id = submarine
		value = 1
	}

	ai_strategy = {
		type = unit_ratio
		id = screen_ship
		value = 1
	}

	ai_strategy = {
		type = unit_ratio
		id = convoy
		value = 1
	}
}


default_area_priority = {
	enable = {
		NOT = { original_tag = PRS } NOT = { original_tag = FRA }
	}

	abort = { always = no }

	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
	}

}

default_stockpile_management = {
	enable = {
		num_divisions > 150
	}

	abort = {
		num_divisions < 130
	}

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


#dont_build_capitals_if_on_treaty = {
#	enable = {
#		has_naval_treaty_trigger = yes
#		not = {
#			OR = {
#				original_tag = JAP
#				original_tag = PIE
#			}
#		}
#	}
#
#	abort = {
#		not = { has_naval_treaty_trigger = yes }
#	}
#
#	ai_strategy = {
#		type = unit_ratio
#		id = capital_ship
#		value = -2		 #1 to 2
#	}
#	ai_strategy = {
#		type = role_ratio
#		id = naval_capital_bb
#		value = -100
#	}
#
#	ai_strategy = {
#		type = role_ratio
#		id = naval_capital_bc
#		value = -100
#	}
#}


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
	}
}

do_not_waste_pp_if_saving_for_manpower_laws = {

	enable = {
		manpower_per_military_factory < 500
		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
	}
}
production_unit_ratios = {
	enable = {
		num_of_factories < num_divisions
	}
	abort = {
		num_of_factories > num_divisions
	}

	ai_strategy = {
		type = role_ratio
		id = paratroopers
		value = 0
	}

	ai_strategy = {
		type = role_ratio
		id = mountaineers
		value = 0
	}

	ai_strategy = {
		type = role_ratio
		id = marines
		value = 0
	}

	ai_strategy = {
		type = role_ratio
		id = armor
		value = 0
	}

	ai_strategy = {
		type = role_ratio
		id = infantry
		value = 0
	}

}

put_garrisons_on_high_prio = {
	enable = {
		date > 1935.01.01
	}
	
	abort = {
		date < 1935.01.01
	}

	ai_strategy = {
		type = garrison_reinforcement_priority
		value = 100 # positive is high prio, negative is low prio
	}
}
