########################################################
#	PRODUCTION MANAGEMENT AI for the divisions
########################################################

produce_ART_AI_for_fuck_sake = {
	enable = {
		has_equipment = { artillery_equipment < 0 }  
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = equipment_variant_production_factor
		id = artillery_equipment
		value = 250
    }
}

produce_AT_AI_for_fuck_sake = {
	enable = {
		has_equipment = { anti_tank_equipment < 0 }  
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = equipment_variant_production_factor
		id = anti_tank_equipment
		value = 500
    }
}

produce_AA_AI_for_fuck_sake = {
	enable = {
		has_equipment = { anti_air_equipment < 0 }
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = equipment_variant_production_factor
		id = anti_air_equipment
		value = 100
    }
}

produce_SUPPORT_EQ_AI_for_fuck_sake = {
	enable = {
		has_equipment = { support_equipment < 0 } 
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = equipment_variant_production_factor
		id = support_equipment
		value = 100
    }
}

produce_MOTORIZED_EQ_for_fuck_sake = {
	enable = {
		has_equipment = { motorized_equipment < 0 } 
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = equipment_variant_production_factor
		id = motorized_equipment
		value = 500
    }
}

produce_MECHANIZED_EQ_for_fuck_sake = {
	enable = {
		has_equipment = { mechanized_equipment < 0 } 
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = equipment_variant_production_factor
		id = mechanized_equipment
		value = 500
    }
}

######################################
#	MISC
######################################

make_trains = {
	enable = { 
		is_eligible_for_armor_production = yes
	}
	abort_when_not_enabled = yes
	ai_strategy = { type = equipment_production_min_factories_archetype id = train_equipment value = 1 }
}

make_trucks = { 
	enable = { 
		is_eligible_for_armor_production = yes
		has_tech = motorised_infantry
		NOT = {has_tech = mechanised_infantry}
	} 
	abort_when_not_enabled = yes
	ai_strategy = { type = equipment_production_min_factories_archetype id = motorized_equipment value = 3 }
}

make_nukes = {
	enable = {
		has_tech = nuclear_reactor
		num_of_civilian_factories > 50
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = building_target
		id = nuclear_reactor 
		value = 5
	}
}

aNCFO_AI_motorized_supplies = {
	enable = {
		is_major = yes
		has_equipment = { motorized_equipment < 1000 }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_production_factor
		id = motorized
		value = 100
	}
}

aNCFO_AI_motorized_surplus = {
	enable = {
		is_major = yes
		has_equipment = { motorized_equipment > 2000 }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_production_factor
		id = motorized
		value = -50
	}
}

aNCFO_AI_train_supplies = {
	enable = {
		is_major = yes
		has_equipment = { train_equipment < 100 }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_production_factor
		id = train
		value = 100
	}
}

always_upgrade_tanks = {
	enable = { always = yes }
	abort_when_not_enabled = yes
	
	ai_strategy = { type = production_upgrade_desire_offset id = light_tank_chassis_1 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = light_tank_chassis_2 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = light_tank_chassis_3 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = medium_tank_chassis_1 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = medium_tank_chassis_2 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = medium_tank_chassis_3 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = heavy_tank_chassis_1 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = heavy_tank_chassis_2 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = heavy_tank_chassis_3 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = modern_tank_chassis value = 100 }
}

always_upgrade_fighters = {
	enable = { always = yes }
	abort_when_not_enabled = yes
	
	ai_strategy = { type = production_upgrade_desire_offset id = small_plane_airframe_1 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = small_plane_airframe_2 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = small_plane_airframe_3 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = small_plane_airframe_4 value = 100 }
}

######################################
#	SP EQUIPMENT FFS
######################################

### MEDIUM ###

produce_SELF_PROPELLED_MEDIUM_ART_for_fuck_sake = {
	enable = {
		OR = {
			has_equipment = { medium_tank_artillery_chassis < 0 }
			## has_equipment = { medium_tank_artillery_equipment < 0 }
		}
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = equipment_variant_production_factor
		id = medium_tank_artillery_chassis
		value = 1000
    }
}

produce_SELF_PROPELLED_MEDIUM_AA_for_fuck_sake = {
	enable = {
		OR = {
			## has_equipment = { medium_tank_aa_equipment < 0 }
			has_equipment = { medium_tank_aa_chassis < 0 }
		}
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = equipment_variant_production_factor
		id = medium_tank_aa_chassis
		value = 1000
    }
}

produce_SELF_PROPELLED_MEDIUM_TANK_DESTROYER_for_fuck_sake = {
	enable = {
		OR = {
			## has_equipment = { medium_tank_destroyer_equipment < 0 }
			has_equipment = { medium_tank_destroyer_chassis < 0 }
		}
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = equipment_variant_production_factor
		id = medium_tank_destroyer_chassis
		value = 1000
    }
}

### LIGHT ###

produce_SELF_PROPELLED_LIGHT_ART_for_fuck_sake = {
	enable = {
		OR = {
			has_equipment = { light_tank_artillery_chassis < 0 }
			## has_equipment = { light_tank_artillery_equipment < 0 }
		}
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = equipment_variant_production_factor
		id = light_tank_artillery_chassis
		value = 500
    }
}

produce_SELF_PROPELLED_LIGHT_AA_for_fuck_sake = {
	enable = {
		OR = {
			## has_equipment = { light_tank_aa_equipment < 0 }
			has_equipment = { light_tank_aa_chassis < 0 }
		}
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = equipment_variant_production_factor
		id = light_tank_aa_chassis
		value = 500
    }
}

produce_SELF_PROPELLED_LIGHT_TANK_DESTROYER_for_fuck_sake = {
	enable = {
		OR = {
			## has_equipment = { light_tank_destroyer_equipment < 0 }
			has_equipment = { light_tank_destroyer_chassis < 0 }
		}
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = equipment_variant_production_factor
		id = light_tank_destroyer_chassis
		value = 500
    }
}

######################################
#	ARMS MARKET MANAGEMENT
######################################

default_market_stockpile_management = {
	enable = {
		always = yes
		# NOT = { original_tag = GER } # commented until actually needs override
	}
	abort_when_not_enabled = yes
	# Hold your trains there, partner
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = train
		value = 20  # only start considering selling trains if surplus more than 20
	}

	ai_strategy = {
		type = equipment_market_min_for_sale
		id = train
		value = 5  # only put up for sale in chunks of 5
	}

	ai_strategy = {
		type = equipment_market_for_sale_factor
		id = train
		value = -50  # put fewer trains up for sale
	}
	# Better not put all your boats up for sail
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = convoy
		value = 100  # only start considering selling convoys if surplus more than 100
	}

	ai_strategy = {
		type = equipment_market_min_for_sale
		id = convoy
		value = 30  # only put up for sale in chunks of 5
	}
	# Don't let all your planes just fly out the window. Only sell planes if we have more than one airwing in surplus.
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = fighter
		value = 100
	}

	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = cas
		value = 100
	}

	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = cv_fighter
		value = 100
	}

	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = cv_cas
		value = 100
	}

	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = tactical_bomber
		value = 100
	}

	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = strategic_bomber
		value = 100
	}
}

default_market_stockpile_management_if_at_war = {
	enable = {
		has_war = yes
		# something something preparing for war?
		# NOT = { original_tag = GER } # commented until actually needs override
	}
	abort_when_not_enabled = yes
	# Don't sell stuff that we need for the war
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = infantry
		value = 20000
	}

	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = support
		value = 6000
	}

	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = artillery
		value = 1000
	}

	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = fighter
		value = 200
	}

	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = motorized
		value = 1000
	}

	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = train
		value = 50
	}

	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = convoy
		value = 50
	}
}

default_market_convoy_purchases = {
	enable = { any_owned_state = { is_coastal = yes } } # not land-locked
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_market_buying_threshold
		id = convoy
		value = 30 # Consider buying if we have too few (less than 30) convoys
	}
}