Update Controllable.lua

This commit is contained in:
Frank 2020-04-24 22:45:45 +02:00
parent c3cc76c15b
commit 68ece29ab5

View File

@ -1056,14 +1056,14 @@ function CONTROLLABLE:TaskFollowBigFormation(FollowControllable, Vec3, LastWaypo
end
--- (AIR) Move the controllable to a Vec2 Point, wait for a defined duration and embark a controllable.
--- (AIR HELICOPTER) Move the controllable to a Vec2 Point, wait for a defined duration and embark infantry groups.
-- @param #CONTROLLABLE self
-- @param DCS#Vec2 Vec2 The point where to wait. Needs to have x and y components.
-- @param Core.Point#COORDINATE Coordinate The point where to pickup the troops.
-- @param Core.Set#SET_GROUP GroupSetForEmbarking Set of groups to embark.
-- @param #number Duration (Optional) The maximum duration in seconds to wait until all groups have embarked.
-- @param Core.Set#SET_GROUP DistributionGroupSet (Optional) Set of groups identifying the groups needing to board specific helicopters.
-- @param #table Distribution (Optional) Distribution used to put the infantry groups into specific carrier units.
-- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, DistributionGroupSet)
function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, Distribution)
-- Table of group IDs for embarking.
local g4e={}
@ -1079,26 +1079,25 @@ function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, Distri
end
-- Table of group IDs for embarking.
local Distribution={}
--local Distribution={}
if DistributionGroupSet then
for _,_group in pairs(DistributionGroupSet:GetSet()) do
local group=_group --Wrapper.Group#GROUP
table.insert(Distribution, group:GetID())
end
end
-- Distribution
--local distribution={}
--distribution[id]=gids
local groupID=self and self:GetID()
local DCSTask = {
id = 'Embarking',
params = {
--selectedTransport = self:GetID(),
selectedTransport = groupID,
Vec2 = Vec2,
x = Vec2.x,
y = Vec2.y,
groupsForEmbarking = g4e,
durationFlag = Duration and true or false,
duration = Duration,
distributionFlag = DistributionGroupSet and true or false,
distributionFlag = Distribution and true or false,
distribution = Distribution,
}
}
@ -1106,73 +1105,24 @@ function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, Distri
return DCSTask
end
--- Used in conjunction with the EmbarkToTransport task for a ground infantry group, the controlled helicopter flight will land at the specified coordinates,
-- pick up boarding troops and transport them to that groups DisembarkFromTransport task.
-- The CONTROLLABLE has to be a helicopter group!
-- @param #CONTROLLABLE self
-- @param Core.Set#SET_GROUP GroupSet Set of groups to be embarked by the controllable.
-- @param Core.Point#COORDINATE Coordinate Coordinate of embarking.
-- @param #number Duration Duration of embarking in seconds.
-- @return #table Embarking task.
function CONTROLLABLE:TaskEmbarking(GroupSet, Coordinate, Duration)
-- Create table of group IDs.
local gids={}
for _,_group in pairs(GroupSet:GetAliveSet()) do
local group=_group --Wrapper.Group#GROUP
table.insert(gids, group:GetID())
end
-- Group ID of controllable.
local id=self:GetID()
-- Distribution
local distribution={}
distribution[id]=gids
local durationFlag=false
if Duration then
durationFlag=true
else
Duration=300
end
local DCStask={
id="Embarking",
params={
distributionFlag=true,
distribution=distribution,
groupsForEmbarking=gids,
durationFlag=durationFlag,
distribution=distribution,
duration=Duration,
x=Coordinate.x,
y=Coordinate.z,
}
}
self:E(DCStask)
return DCStask
end
--- Used in conjunction with the embarking task for a transport helicopter group. The Ground units will move to the specified location and wait to be picked up by a helicopter.
-- The helicopter will then fly them to their dropoff point defined by another task for the ground forces; DisembarkFromTransport task.
-- The controllable has to be an infantry group!
-- @param #CONTROLLABLE self
-- @param Core.Point#COORDINATE Coordinate Coordinates where AI is expecting to be picked up.
-- @param #number Radius Radius in meters.
-- @return #table Embark to transport task.
function CONTROLLABLE:TaskEmbarkToTransport(Coordinate, Radius)
-- @param #number Radius Radius in meters. Default 200 m.
-- @param #string UnitType The unit type name of the carrier, e.g. "UH-1H". Must not be specified.
-- @return DCS#Task Embark to transport task.
function CONTROLLABLE:TaskEmbarkToTransport(Coordinate, Radius, UnitType)
local EmbarkToTransport = {
id="EmbarkToTransport",
id = "EmbarkToTransport",
params={
x=Coordinate.x,
y=Coordinate.z,
zoneRadius=Radius,
--selectedType="UH-1H",
x = Coordinate.x,
y = Coordinate.z,
zoneRadius = Radius or 200,
selectedType = UnitType,
}
}
@ -1180,21 +1130,31 @@ function CONTROLLABLE:TaskEmbarkToTransport(Coordinate, Radius)
end
--- Specifies the location an infantry group that is being transported by helicopters will be unloaded at. Used in conjunction with the EmbarkToTransport task.
-- The CONTROLLABLE has to be an infantry group!
--- Specifies the location infantry groups that is being transported by helicopters will be unloaded at. Used in conjunction with the EmbarkToTransport task.
-- @param #CONTROLLABLE self
-- @param Core.Point#COORDINATE Coordinate Coordinates where AI is expecting to be picked up.
-- @param #number Radius Radius in meters.
-- @return #table Embark to transport task.
function CONTROLLABLE:TaskDisembarkFromTransport(Coordinate, Radius)
-- @return DCS#Task Embark to transport task.
function CONTROLLABLE:TaskDisembarking(Coordinate, GroupSetToDisembark)
-- Table of group IDs for disembarking.
local g4e={}
if GroupSetToDisembark then
for _,_group in pairs(GroupSetToDisembark:GetSet()) do
local group=_group --Wrapper.Group#GROUP
table.insert(g4e, group:GetID())
end
else
self:E("ERROR: No groups for disembarking specified!")
return nil
end
local DisembarkFromTransport={
id="DisembarkFromTransport",
params = {
x=Coordinate.x,
y=Coordinate.y,
zoneRadius=Radius,
x = Coordinate.x,
y = Coordinate.z,
groupsForEmbarking = g4e, -- This is no bug, the entry is really "groupsForEmbarking" even if we disembark the troops.
}
}
@ -1202,28 +1162,6 @@ function CONTROLLABLE:TaskDisembarkFromTransport(Coordinate, Radius)
end
--- (GROUND) Embark to a Transport landed at a location.
-- Move to a defined Vec2 Point, and embark to a controllable when arrived within a defined Radius.
-- @param #CONTROLLABLE self
-- @param DCS#Vec2 Point The point where to wait.
-- @param #number Radius The radius of the embarking zone around the Point.
-- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskEmbarkToTransport( Point, Radius )
local DCSTask = {
id = 'EmbarkToTransport',
params = {
point = Point,
x = Point.x,
y = Point.y,
zoneRadius = Radius,
}
}
return DCSTask
end
--- (AIR) Orbit at a specified position at a specified alititude during a specified duration with a specified speed.
-- @param #CONTROLLABLE self
-- @param DCS#Vec2 Point The point to hold the position.