-- $Id: para.lua 25-July-2009 Frogs Friend $

para = {}
para.detail = para.detail or {};


--[[
Infantry_Full_Plane	0
Anti_Tank_Team_5_men	1
Commandos_8_men		2 
Specialists_9_men		3
Heavy_Weapons		4
Ammo/Fuel			5
flamethrowers_10_men	6
--]]

-- Maximum troops in transport: germany =18, ussr =28, usa =28, uk =28, japan =16, france =20

para.detail.airborne =
{
	germany = {
		[0] = {
			{desc = "Units/Soldiers/German/german_officer.dsc", num=2},
			{desc = "Units/Soldiers/German/german_medic.dsc", num=1},
			{desc = "Units/Soldiers/German/german_smg.dsc", num=2},
			{desc = "Units/Soldiers/German/german_rifleman.dsc", num=6},
			{desc = "Units/Soldiers/German/german_lmg_mg42.dsc", num=2},
			{desc = "Units/Soldiers/German/german_flammenwerfer.dsc", num=1},
			{desc = "Units/Soldiers/German/german_sniper.dsc", num=1},
			{desc = "Units/Soldiers/German/german_mech.dsc", num=1},
			{desc = "Units/Soldiers/German/german_panzerschreck.dsc", num=1},
			{desc = "Units/Soldiers/German/german_sapper.dsc", num=1},
		},
		[1] = {
			{desc = "Units/Soldiers/German/german_officer.dsc", num=1},
			{desc = "Units/Soldiers/German/german_panzerschreck.dsc", num=2},
			{desc = "Units/Soldiers/German/german_sniper.dsc", num=1},
			{desc = "Units/Soldiers/German/german_smg.dsc", num=1},
		},
		[2] = {
			{desc = "Units/Soldiers/German/german_officer.dsc", num=1},
			{desc = "Units/Soldiers/German/german_sniper.dsc", num=2},
			{desc = "Units/Soldiers/German/german_medic.dsc", num=1},
			{desc = "Units/Soldiers/saboteur.dsc", num=4},
		},
		[3] = {
			{desc = "Units/Soldiers/German/german_officer.dsc", num = 1},
			{desc = "Units/Soldiers/German/german_medic.dsc", num = 1},
			{desc = "Units/Soldiers/German/german_mech.dsc", num = 1},
			{desc = "Units/Soldiers/German/german_sniper.dsc", num = 2},
			{desc = "Units/Soldiers/German/german_flammenwerfer.dsc", num = 1},
			{desc = "Units/Soldiers/German/german_sapper.dsc", num = 2},
			{desc = "Units/Soldiers/German/german_panzerschreck.dsc", num = 1},
		},
		[4] = {
			{desc = "Units/Vehicles/Transports/German/kfz1_vw82.dsc", num = 1},
			{desc = "Units/Artillery/Mg/german/mg42_schweres.dsc", num = 1},
			{desc = "Units/Artillery/Antitank/German/5cm_pak38.dsc", num = 1},
			{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 1},
			{desc = "Units/Artillery/Field/German/7_5cm_le_ig18.dsc", num = 1},
			{desc = "Units/Artillery/Mortars/german/8cm_grwr34.dsc", num = 1},
		},
		[5] = {
			{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 3},
			{desc = "Objects/ammo_boxes/fuel_800.dsc", num = 3},
		},
		[6] = {
			{desc = "Units/Soldiers/German/german_flammenwerfer.dsc", num = 8},
			{desc = "Units/Soldiers/German/german_medic.dsc", num = 1},
			{desc = "Units/Soldiers/German/german_officer.dsc", num = 1},
		},
	},
	usa = {
		[0] = {
			{desc = "Mods/Sword Beach/american_airborne_officer.dsc", num=1},
			{desc = "Mods/Sword Beach/american_airborne_medic.dsc", num=1},
			{desc = "Mods/Sword Beach/american_airborne_bazooka.dsc", num=2},
			{desc = "Mods/Sword Beach/american_airborne_lmg_30c.dsc", num=4},
			{desc = "Mods/Sword Beach/american_airborne_flamethrower.dsc", num=2},
			{desc = "Mods/Sword Beach/american_airborne_sniper.dsc", num=2},
			{desc = "Mods/Sword Beach/american_airborne_rifleman.dsc", num=10},
			{desc = "Mods/Sword Beach/american_airborne_smg.dsc", num=6},
		},
		[1] = {
			{desc = "Mods/Sword Beach/american_airborne_officer.dsc", num=1},
			{desc = "Mods/Sword Beach/american_airborne_bazooka.dsc", num=2},
			{desc = "Mods/Sword Beach/american_airborne_sniper.dsc", num=1},
			{desc = "Mods/Sword Beach/american_airborne_smg.dsc", num=1},
		},
		[2] = {
			{desc = "Mods/Sword Beach/american_airborne_officer.dsc", num=1},
			{desc = "Mods/Sword Beach/american_airborne_sniper.dsc", num=2},
			{desc = "Mods/Sword Beach/american_airborne_medic.dsc", num=1},
			{desc = "Units/Soldiers/saboteur.dsc", num=4},
		},
		[3] = {
			{desc = "Mods/Sword Beach/american_airborne_officer.dsc", num = 1},
			{desc = "Mods/Sword Beach/american_airborne_medic.dsc", num = 1},
			{desc = "Mods/Sword Beach/american_airborne_mech.dsc", num = 1},
			{desc = "Mods/Sword Beach/american_airborne_sniper.dsc", num = 2},
			{desc = "Mods/Sword Beach/american_airborne_flamethrower.dsc", num = 1},
			{desc = "Mods/Sword Beach/american_airborne_sapper.dsc", num = 2},
			{desc = "Mods/Sword Beach/american_airborne_bazooka.dsc", num = 1},
		},
		[4] = {
			{desc = "Mods/Sword Beach/american_airborne_willys_supply.dsc", num = 1},
			{desc = "Mods/Sword Beach/american_airborne_37mm_m3a1.dsc", num = 1},
			{desc = "Mods/Sword Beach/american_airborne_50_cal_hmg.dsc", num = 1},
			{desc = "Mods/Sword Beach/american_airborne_75mm_m1a1.dsc", num = 1},
			{desc = "Mods/Sword Beach/american_airborne_81mm_m1.dsc", num = 1},
			{desc = "Mods/Sword Beach/american_airborne_willys_lmg_50c.dsc", num = 1},
		},
		[5] = {
			{desc = "Mods/Sword Beach/american_airborne_willys_supply.dsc", num = 2},
			{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 3},
			{desc = "Objects/ammo_boxes/fuel_800.dsc", num = 3},
		},
		[6] = {
			{desc = "Mods/Sword Beach/american_airborne_flamethrower.dsc", num = 8},
			{desc = "Mods/Sword Beach/american_airborne_medic.dsc", num = 1},
			{desc = "Mods/Sword Beach/american_airborne_officer.dsc", num = 1},
		},
	},
	uk = {
		[0] = {
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_officer.dsc", num=1},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_medic.dsc", num=2},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_smg.dsc", num=6},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_rifleman.dsc", num=8},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_lmg_bren.dsc", num=4},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_flamethrower.dsc", num=2},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_sniper.dsc", num=2},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_PIAT_atgun.dsc", num=2},
		},
		[1] = {
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_officer.dsc", num=1},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_PIAT_atgun.dsc", num=2},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_sniper.dsc", num=1},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_smg.dsc", num=1},
		},
		[2] = {
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_officer.dsc", num=1},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_sniper.dsc", num=2},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_medic.dsc", num=1},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_saboteur.dsc", num=4},
		},
		[3] = {
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_officer.dsc", num = 1},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_medic.dsc", num = 1},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_mech.dsc", num = 1},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_sniper.dsc", num = 2},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_flamethrower.dsc", num = 1},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_sapper.dsc", num = 2},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_PIAT_atgun.dsc", num = 1},
		},
		[4] = {
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_willys_supply.dsc", num = 1},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_6p_qf_mk_ii.dsc", num = 1},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_vickers_medium.dsc", num = 1},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_3_7inch_inf_howitzer_mk_ii.dsc", num = 1},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_76mm_mortar_mkii.dsc", num = 1},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_willys_lmg_50c.dsc", num = 1},
		},
		[5] = {
			{desc = "Units/Paratroopers/Vehicles/british/british_airborne_willys_supply.dsc", num = 2},
			{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 3},
			{desc = "Objects/ammo_boxes/fuel_800.dsc", num = 3},
		},
		[6] = {
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_flamethrower.dsc", num = 8},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_medic.dsc", num = 1},
			{desc = "Units/Paratroopers/Soldiers/british/british_airborne_officer.dsc", num = 1},
		},
	},
}

function para.airborne(player_nation, reinf_type)
	assert(player_nation and reinf_type, "one argument is nil");
	local nation = para.detail.airborne[player_nation];
	return nation[reinf_type];
end

function para.ParaPlane(Player, Position, Gate, GateOut, Radius, Cargo, CargoGroup)
	Radius = Radius or 5
	local s = AIparts:AddOneTime(AIparts:GetUniqueId("PLANE"), 1, function(self) mission_lua.PlaneBonus(self) end);
	local p = GetPlayer(Player);
	s.player = p.Id;
	local pos = utils.copy_value(mission.Waypoints[Position]);
	if s.position then s.position = GetRandomRadiusPoint(s.position, Radius) end
	s.desc = utils.getplane(p.CountryName, "transport")
	s.gate = Gate
	s.cargo = para.airborne(p.CountryName, Cargo)
	s.cargo.group = CargoGroup
	s.commands = {{unload_to = pos}, {dislocation = mission_lua.CalculateGate(GateOut)}, {disappear = true}}
end

function para.IsObjectDestroyed(ObjectId)
	local object = GetObject(ObjectId)
	if object then
		return object.Health
	else
		return 0
	end
end

function para.GetPlayer(ObjectId)
	local object = GetObject(ObjectId)
	if object then
		return object.PlayerId
	else
		return 99
	end
end