Rework of SPAWN

- Visible Array
- Internal table in SPAWN
GROUP functions
- Route
- RouteToZone
- CopyRoute
SPAWN functions
- SpawnFromUnit
- SpawnInZone

Replaced SpawnFromCarrier overall
This commit is contained in:
svenvandevelde
2016-03-06 08:50:28 +01:00
parent effc400a46
commit 17bfcf8373
13 changed files with 872 additions and 439 deletions

View File

@@ -10,8 +10,8 @@ _TraceClass = {
--SEAD = true,
--DESTROYBASETASK = true,
--MOVEMENT = true,
--SPAWN = true,
--GROUP = true,
SPAWN = true,
GROUP = true,
--UNIT = true,
}

View File

@@ -52,13 +52,13 @@ function CARGO_ZONE:Spawn()
self:T( CargoHostSpawn )
if self.CargoHostSpawn then
local CargoHostGroup = Group.getByName( self.CargoHostSpawn:SpawnGroupName() )
local CargoHostGroup = self.CargoHostSpawn:GetGroupFromIndex():GetDCSGroup()
if CargoHostGroup then
if not CargoHostGroup:isExist() then
self.CargoHostSpawn:ReSpawn()
self.CargoHostSpawn:ReSpawn(1)
end
else
self.CargoHostSpawn:ReSpawn()
self.CargoHostSpawn:ReSpawn(1)
end
end
@@ -70,7 +70,7 @@ function CARGO_ZONE:GetHostUnit()
if self.CargoHostName then
-- A Host has been given, signal the host
local CargoHostGroup = Group.getByName( self.CargoHostSpawn:SpawnGroupName() )
local CargoHostGroup = self.CargoHostSpawn:GetGroupFromIndex():GetDCSGroup()
local CargoHostUnit
if CargoHostGroup == nil then
CargoHostUnit = StaticObject.getByName( self.CargoHostName )
@@ -253,8 +253,8 @@ end
function CARGO_ZONE:GetCargoHostUnit()
self:T()
local CargoHostUnit = Group.getByName( self.CargoHostSpawn:SpawnGroupName() ):getUnit(1)
if CargoHostUnit and CargoHostUnit:isExist() then
local CargoHostUnit = self.CargoHostSpawn:GetGroupFromIndex(1):GetUnit(1)
if CargoHostUnit and CargoHostUnit:IsAlive() then
return CargoHostUnit
end
@@ -347,7 +347,7 @@ self:T()
local Valid = true
self.CargoClient = Client
local ClientUnit = Client:GetClientGroupUnit()
local ClientUnit = Client:GetClientGroupDCSUnit()
return Valid
end
@@ -499,10 +499,10 @@ self:T()
if SpawnCargo then
if self.CargoZone:GetCargoHostUnit() then
--- ReSpawn the Cargo from the CargoHost
self.CargoGroupName = self.CargoSpawn:FromHost( self.CargoZone:GetCargoHostUnit(), 60, 30, self.CargoName, false ).name
self.CargoGroupName = self.CargoSpawn:SpawnFromUnit( self.CargoZone:GetCargoHostUnit(), 60, 30 ):GetName()
else
--- ReSpawn the Cargo in the CargoZone without a host ...
self.CargoGroupName = self.CargoSpawn:InZone( self.CargoZone:GetCargoZoneName(), self.CargoName ).name
self.CargoGroupName = self.CargoSpawn:SpawnInZone( self.CargoZone ):GetName()
end
self:StatusNone()
end
@@ -534,7 +534,7 @@ self:T()
local Valid = true
local ClientUnit = Client:GetClientGroupUnit()
local ClientUnit = Client:GetClientGroupDCSUnit()
local CarrierPos = ClientUnit:getPoint()
local CarrierPosMove = ClientUnit:getPoint()
@@ -630,8 +630,10 @@ self:T()
self:T( 'self.CargoName = ' .. self.CargoName )
self:T( 'self.CargoGroupName = ' .. self.CargoGroupName )
self.CargoSpawn:FromCarrier( Client:GetClientGroupUnit(), TargetZoneName, self.CargoGroupName )
--self.CargoSpawn:FromCarrier( Client:GetClientGroupDCSUnit(), TargetZoneName, self.CargoGroupName )
self.CargoSpawn:SpawnFromUnit( Client:GetClientGroupUnit(), self.CargoGroupName ):RouteToZone( ZONE:New( TargetZoneName ) )
self:StatusUnLoaded()
return self
@@ -666,7 +668,7 @@ self:T()
if not self.CargoClientInitGroupSpawn then
self.CargoClientInitGroupSpawn = SPAWN:New( self.CargoClient:GetClientGroupName() )
end
self.CargoClientInitGroupSpawn:Spawn( self.CargoClient:GetClientGroupName() )
self.CargoClientInitGroupSpawn:ReSpawn( 1 )
end
local SpawnCargo = true
@@ -705,7 +707,7 @@ self:T()
self:T( self.CargoClient.ClientName )
self:T( 'Client Exists.' )
if routines.IsUnitInRadius( self.CargoClient:GetClientGroupUnit(), Client:ClientPosition(), 150 ) then
if routines.IsUnitInRadius( self.CargoClient:GetClientGroupDCSUnit(), Client:ClientPosition(), 150 ) then
Near = true
end
end
@@ -720,7 +722,7 @@ self:T()
local Valid = true
local ClientUnit = Client:GetClientGroupUnit()
local ClientUnit = Client:GetClientGroupDCSUnit()
local CarrierPos = ClientUnit:getPoint()
local CarrierPosMove = ClientUnit:getPoint()
@@ -812,7 +814,7 @@ self:T()
local OnBoarded = false
if self.CargoClient and self.CargoClient:ClientGroup() then
if routines.IsUnitInRadius( self.CargoClient:GetClientGroupUnit(), self.CargoClient:ClientPosition(), 10 ) then
if routines.IsUnitInRadius( self.CargoClient:GetClientGroupDCSUnit(), self.CargoClient:ClientPosition(), 10 ) then
-- Switch Cargo from self.CargoClient to Client ... Each cargo can have only one client. So assigning the new client for the cargo is enough.
self:StatusLoaded( Client )

View File

@@ -175,6 +175,24 @@ self:T()
local ClientGroup = self:ClientGroup()
if ClientGroup then
if ClientGroup:isExist() then
return UNIT:New( ClientGroup:getUnit(1) )
else
return UNIT:New( self.ClientGroupUnit )
end
end
return nil
end
--- Returns the DCSUnit of the @{CLIENT}.
-- @treturn DCSUnit
function CLIENT:GetClientGroupDCSUnit()
self:T()
local ClientGroup = self:ClientGroup()
if ClientGroup then
if ClientGroup:isExist() then
return ClientGroup:getUnits()[1]
@@ -189,7 +207,7 @@ end
function CLIENT:GetUnit()
self:T()
return UNIT:New( self:GetClientGroupUnit() )
return UNIT:New( self:GetClientGroupDCSUnit() )
end
@@ -198,7 +216,7 @@ end
function CLIENT:ClientPosition()
--self:T()
ClientGroupUnit = self:GetClientGroupUnit()
ClientGroupUnit = self:GetClientGroupDCSUnit()
if ClientGroupUnit then
if ClientGroupUnit:isExist() then
@@ -294,7 +312,7 @@ self:T()
end
MESSAGE:New( Message, MessageCategory, MessageDuration, MessageId ):ToClient( self )
else
if self:GetClientGroupUnit() and not self:GetClientGroupUnit():inAir() then
if self:GetClientGroupDCSUnit() and not self:GetClientGroupDCSUnit():inAir() then
if timer.getTime() - self.Messages[MessageId].MessageTime >= self.Messages[MessageId].MessageDuration + 10 then
MESSAGE:New( Message, MessageCategory, MessageDuration, MessageId ):ToClient( self )
self.Messages[MessageId].MessageTime = timer.getTime()

View File

@@ -5,6 +5,7 @@
Include.File( "Routines" )
Include.File( "Base" )
Include.File( "Menu" )
Include.File( "Group" )
DATABASE = {
ClassName = "DATABASE",
@@ -138,6 +139,9 @@ function DATABASE:Spawn( SpawnTemplate )
self:_RegisterGroup( SpawnTemplate )
coalition.addGroup( SpawnCountryID, SpawnCategoryID, SpawnTemplate )
local SpawnGroup = GROUP:New( Group.getByName( SpawnTemplate.name ) )
return SpawnGroup
end
@@ -206,7 +210,7 @@ end
--- Track DCSRTE DEAD or CRASH events for the internal scoring.
function DATABASE:OnDeadOrCrash( event )
self:T( { event } )
--self:T( { event } )
local TargetUnit = nil
local TargetGroup = nil
@@ -241,7 +245,7 @@ function DATABASE:OnDeadOrCrash( event )
TargetUnitCategory = DATABASECategory[TargetCategory]
TargetUnitType = TargetType
self:T( { TargetUnitName, TargetGroupName, TargetPlayerName, TargetCoalition, TargetCategory, TargetType } )
--self:T( { TargetUnitName, TargetGroupName, TargetPlayerName, TargetCoalition, TargetCategory, TargetType } )
end
for PlayerName, PlayerData in pairs( self.Players ) do

View File

@@ -13,13 +13,14 @@ GROUP = {
ClassName="GROUP",
}
function GROUP:New( _Group )
function GROUP:New( DCSGroup )
local self = BASE:Inherit( self, BASE:New() )
self:T( _Group:getName() )
self:T( DCSGroup:getName() )
self._Group = _Group
self.GroupName = _Group:getName()
self.GroupID = _Group:getID()
self.DCSGroup = DCSGroup
self.GroupName = DCSGroup:getName()
self.GroupID = DCSGroup:getID()
self.Controller = DCSGroup:getController()
return self
end
@@ -29,13 +30,29 @@ function GROUP:NewFromName( GroupName )
local self = BASE:Inherit( self, BASE:New() )
self:T( GroupName )
self._Group = Group.getByName( GroupName )
self.GroupName = self._Group:getName()
self.GroupID = self._Group:getID()
self.DCSGroup = Group.getByName( GroupName )
self.GroupName = self.DCSGroup:getName()
self.GroupID = self.DCSGroup:getID()
return self
end
function GROUP:GetDCSGroup()
self:T( { self.GroupName } )
return self.DCSGroup
end
function GROUP:GetDCSUnit( UnitNumber )
self:T( { self.GroupName, UnitNumber } )
return self.DCSGroup:getUnit( UnitNumber )
end
function GROUP:Activate()
self:T( { self.GroupName } )
trigger.action.activateGroup( self:GetDCSGroup() )
return self:GetDCSGroup()
end
function GROUP:GetName()
self:T( self.GroupName )
@@ -43,40 +60,59 @@ function GROUP:GetName()
return self.GroupName
end
function GROUP:GetPoint()
self:T( self.GroupName )
local GroupPoint = self:GetUnit(1):GetPoint()
self:T( GroupPoint )
return GroupPoint
end
function GROUP:Destroy()
self:T( self.GroupName )
for Index, UnitData in pairs( self._Group:getUnits() ) do
for Index, UnitData in pairs( self.DCSGroup:getUnits() ) do
self:CreateEventCrash( timer.getTime(), UnitData )
end
self._Group:destroy()
self.DCSGroup:destroy()
end
function GROUP:GetUnit( UnitNumber )
self:T( self.GroupName )
return UNIT:New( self._Group:getUnit( UnitNumber ) )
self:T( { self.GroupName, UnitNumber } )
return UNIT:New( self.DCSGroup:getUnit( UnitNumber ) )
end
function GROUP:IsAir()
self:T()
local IsAirResult = self._Group:getCategory() == Group.Category.AIRPLANE or self._Group:getCategory() == Group.Category.HELICOPTER
local IsAirResult = self.DCSGroup:getCategory() == Group.Category.AIRPLANE or self.DCSGroup:getCategory() == Group.Category.HELICOPTER
self:T( IsAirResult )
return IsAirResult
end
function GROUP:IsAlive()
self:T()
local IsAliveResult = self.DCSGroup and self.DCSGroup:isExist()
self:T( IsAliveResult )
return IsAliveResult
end
function GROUP:AllOnGround()
self:T()
local AllOnGroundResult = true
for Index, UnitData in pairs( self._Group:getUnits() ) do
for Index, UnitData in pairs( self.DCSGroup:getUnits() ) do
if UnitData:inAir() then
AllOnGroundResult = false
end
@@ -92,7 +128,7 @@ self:T()
local MaxVelocity = 0
for Index, UnitData in pairs( self._Group:getUnits() ) do
for Index, UnitData in pairs( self.DCSGroup:getUnits() ) do
local Velocity = UnitData:getVelocity()
local VelocityTotal = math.abs( Velocity.x ) + math.abs( Velocity.y ) + math.abs( Velocity.z )
@@ -129,13 +165,13 @@ end
function GROUP:Embarking( Point, Duration, EmbarkingGroup )
trace.f( self.ClassName, { self.GroupName, Point, Duration, EmbarkingGroup._Group } )
trace.f( self.ClassName, { self.GroupName, Point, Duration, EmbarkingGroup.DCSGroup } )
local Controller = self:_GetController()
trace.i( self.ClassName, EmbarkingGroup.GroupID )
trace.i( self.ClassName, EmbarkingGroup._Group:getID() )
trace.i( self.ClassName, EmbarkingGroup._Group.id )
trace.i( self.ClassName, EmbarkingGroup.DCSGroup:getID() )
trace.i( self.ClassName, EmbarkingGroup.DCSGroup.id )
Controller:pushTask( { id = 'Embarking',
params = { x = Point.x,
@@ -169,9 +205,112 @@ trace.f( self.ClassName, { self.GroupName, Point, Radius } )
return self
end
function GROUP:Route( GoPoints )
self:T( GoPoints )
local Points = routines.utils.deepCopy( GoPoints )
local MissionTask = { id = 'Mission', params = { route = { points = Points, }, }, }
--self.Controller.setTask( self.Controller, MissionTask )
routines.scheduleFunction( self.Controller.setTask, { self.Controller, MissionTask}, timer.getTime() + 1 )
return self
end
function GROUP:RouteToZone( Zone, Randomize, Speed, Formation )
self:T( Zone )
local GroupPoint = self:GetPoint()
local PointFrom = {}
PointFrom.x = GroupPoint.x
PointFrom.y = GroupPoint.y
PointFrom.type = "Turning Point"
PointFrom.action = "Cone"
PointFrom.speed = 20 / 1.6
local PointTo = {}
local ZonePoint
if Randomize then
ZonePoint = Zone:GetRandomPoint()
else
ZonePoint = Zone:GetPoint()
end
PointTo.x = ZonePoint.x
PointTo.y = ZonePoint.y
PointTo.type = "Turning Point"
if Formation then
PointTo.action = Formation
else
PointTo.action = "Cone"
end
if Speed then
PointTo.speed = Speed
else
PointTo.speed = 20 / 1.6
end
local Points = { PointFrom, PointTo }
self:T( Points )
self:Route( Points )
return self
end
function GROUP:CopyRoute( Begin, End, Randomize, Radius )
self:T( { Begin, End } )
local Points = {}
-- Could be a Spawned Group
local GroupName = string.match( self:GetName(), ".*#" )
if GroupName then
GroupName = GroupName:sub( 1, -2 )
else
GroupName = self:GetName()
end
self:T( { GroupName } )
local Template = _Database.Groups[GroupName].Template
if Template then
if not Begin then
Begin = 0
end
if not End then
End = 0
end
for TPointID = Begin + 1, #Template.route.points - End do
if Template.route.points[TPointID] then
Points[#Points+1] = routines.utils.deepCopy( Template.route.points[TPointID] )
if Randomize then
if not Radius then
Radius = 500
end
Points[#Points].x = Points[#Points].x + math.random( Radius * -1, Radius )
Points[#Points].y = Points[#Points].y + math.random( Radius * -1, Radius )
end
end
end
return Points
end
return nil
end
function GROUP:_GetController()
return self._Group:getController()
return self.DCSGroup:getController()
end

View File

@@ -174,12 +174,12 @@ function MISSION:ReportToAll()
local AlivePlayers = ''
for ClientID, Client in pairs( self._Clients ) do
if Client:ClientGroup() then
if Client:GetClientGroupUnit() then
if Client:GetClientGroupUnit():getLife() > 0.0 then
if Client:GetClientGroupDCSUnit() then
if Client:GetClientGroupDCSUnit():getLife() > 0.0 then
if AlivePlayers == '' then
AlivePlayers = ' Players: ' .. Client:GetClientGroupUnit():getPlayerName()
AlivePlayers = ' Players: ' .. Client:GetClientGroupDCSUnit():getPlayerName()
else
AlivePlayers = AlivePlayers .. ' / ' .. Client:GetClientGroupUnit():getPlayerName()
AlivePlayers = AlivePlayers .. ' / ' .. Client:GetClientGroupDCSUnit():getPlayerName()
end
end
end
@@ -486,7 +486,7 @@ trace.scheduled("MISSIONSCHEDULER","Scheduler")
if Mission.GoalFunction ~= nil then
Mission.GoalFunction( Mission, Client )
end
_Database:_AddMissionTaskScore( Client:GetClientGroupUnit(), Mission.Name, 25 )
_Database:_AddMissionTaskScore( Client:GetClientGroupDCSUnit(), Mission.Name, 25 )
-- if not Mission:IsCompleted() then
-- end

View File

@@ -66,41 +66,51 @@ routines.utils.oneLineSerialize = function(tbl) -- serialization of a table all
tbl_str[#tbl_str + 1] = '{'
for ind,val in pairs(tbl) do -- serialize its fields
local ind_str = {}
if type(ind) == "number" then
tbl_str[#tbl_str + 1] = '['
tbl_str[#tbl_str + 1] = tostring(ind)
tbl_str[#tbl_str + 1] = ']='
ind_str[#ind_str + 1] = '['
ind_str[#ind_str + 1] = tostring(ind)
ind_str[#ind_str + 1] = ']='
else --must be a string
tbl_str[#tbl_str + 1] = '['
tbl_str[#tbl_str + 1] = routines.utils.basicSerialize(ind)
tbl_str[#tbl_str + 1] = ']='
ind_str[#ind_str + 1] = '['
ind_str[#ind_str + 1] = routines.utils.basicSerialize(ind)
ind_str[#ind_str + 1] = ']='
end
local val_str = {}
if ((type(val) == 'number') or (type(val) == 'boolean')) then
tbl_str[#tbl_str + 1] = tostring(val)
tbl_str[#tbl_str + 1] = ','
elseif type(val) == 'string' then
tbl_str[#tbl_str + 1] = routines.utils.basicSerialize(val)
tbl_str[#tbl_str + 1] = ','
val_str[#val_str + 1] = tostring(val)
val_str[#val_str + 1] = ','
tbl_str[#tbl_str + 1] = table.concat(ind_str)
tbl_str[#tbl_str + 1] = table.concat(val_str)
elseif type(val) == 'string' then
val_str[#val_str + 1] = routines.utils.basicSerialize(val)
val_str[#val_str + 1] = ','
tbl_str[#tbl_str + 1] = table.concat(ind_str)
tbl_str[#tbl_str + 1] = table.concat(val_str)
elseif type(val) == 'nil' then -- won't ever happen, right?
tbl_str[#tbl_str + 1] = 'nil,'
val_str[#val_str + 1] = 'nil,'
tbl_str[#tbl_str + 1] = table.concat(ind_str)
tbl_str[#tbl_str + 1] = table.concat(val_str)
elseif type(val) == 'table' then
if ind == "__index" then
tbl_str[#tbl_str + 1] = "__index"
tbl_str[#tbl_str + 1] = ',' --I think this is right, I just added it
-- tbl_str[#tbl_str + 1] = "__index"
-- tbl_str[#tbl_str + 1] = ',' --I think this is right, I just added it
else
tbl_str[#tbl_str + 1] = _Serialize(val)
tbl_str[#tbl_str + 1] = ',' --I think this is right, I just added it
val_str[#val_str + 1] = _Serialize(val)
val_str[#val_str + 1] = ',' --I think this is right, I just added it
tbl_str[#tbl_str + 1] = table.concat(ind_str)
tbl_str[#tbl_str + 1] = table.concat(val_str)
end
elseif type(val) == 'function' then
tbl_str[#tbl_str + 1] = "function " .. tostring(ind)
tbl_str[#tbl_str + 1] = ',' --I think this is right, I just added it
-- tbl_str[#tbl_str + 1] = "function " .. tostring(ind)
-- tbl_str[#tbl_str + 1] = ',' --I think this is right, I just added it
else
env.info('unable to serialize value type ' .. routines.utils.basicSerialize(type(val)) .. ' at index ' .. tostring(ind))
env.info( debug.traceback() )
-- env.info('unable to serialize value type ' .. routines.utils.basicSerialize(type(val)) .. ' at index ' .. tostring(ind))
-- env.info( debug.traceback() )
end
end
tbl_str[#tbl_str + 1] = '}'
return table.concat(tbl_str)

File diff suppressed because it is too large Load Diff

View File

@@ -226,7 +226,7 @@ self:T()
local RouteMessage = "Fly to "
self:T( Task.LandingZones )
for LandingZoneID, LandingZoneName in pairs( Task.LandingZones.LandingZoneNames ) do
RouteMessage = RouteMessage .. LandingZoneName .. ' at ' .. routines.getBRStringZone( { zone = LandingZoneName, ref = Client:GetClientGroupUnit():getPoint(), true, true } ) .. ' km. '
RouteMessage = RouteMessage .. LandingZoneName .. ' at ' .. routines.getBRStringZone( { zone = LandingZoneName, ref = Client:GetClientGroupDCSUnit():getPoint(), true, true } ) .. ' km. '
end
Client:Message( RouteMessage, self.MSG.TIME, Mission.Name .. "/StageRoute", "Co-Pilot: Route", 20 )
@@ -243,7 +243,7 @@ self:T()
-- check if the Client is in the landing zone
self:T( Task.LandingZones.LandingZoneNames )
Task.CurrentLandingZoneName = routines.IsUnitInZones( Client:GetClientGroupUnit(), Task.LandingZones.LandingZoneNames )
Task.CurrentLandingZoneName = routines.IsUnitInZones( Client:GetClientGroupDCSUnit(), Task.LandingZones.LandingZoneNames )
if Task.CurrentLandingZoneName then
@@ -331,7 +331,7 @@ end
function STAGELANDING:Validate( Mission, Client, Task )
self:T()
Task.CurrentLandingZoneName = routines.IsUnitInZones( Client:GetClientGroupUnit(), Task.LandingZones.LandingZoneNames )
Task.CurrentLandingZoneName = routines.IsUnitInZones( Client:GetClientGroupDCSUnit(), Task.LandingZones.LandingZoneNames )
if Task.CurrentLandingZoneName then
-- Client is in de landing zone.
@@ -357,7 +357,7 @@ self:T()
return -1
end
if Task.IsLandingRequired and Client:GetClientGroupUnit():inAir() then
if Task.IsLandingRequired and Client:GetClientGroupDCSUnit():inAir() then
return 0
end
@@ -397,14 +397,14 @@ end
function STAGELANDED:Validate( Mission, Client, Task )
self:T()
if not routines.IsUnitInZones( Client:GetClientGroupUnit(), Task.CurrentLandingZoneName ) then
if not routines.IsUnitInZones( Client:GetClientGroupDCSUnit(), Task.CurrentLandingZoneName ) then
self:T( "Client is not anymore in the landing zone, go back to stage Route, and remove cargo menus." )
Task.Signalled = false
Task:RemoveCargoMenus( Client )
return -2
end
if Task.IsLandingRequired and Client:GetClientGroupUnit():inAir() then
if Task.IsLandingRequired and Client:GetClientGroupDCSUnit():inAir() then
self:T( "Client went back in the air. Go back to stage Landing." )
Task.Signalled = false
return -1
@@ -464,7 +464,7 @@ function STAGEUNLOAD:Validate( Mission, Client, Task )
self:T()
env.info( 'STAGEUNLOAD:Validate()' )
if routines.IsUnitInZones( Client:GetClientGroupUnit(), Task.CurrentLandingZoneName ) then
if routines.IsUnitInZones( Client:GetClientGroupDCSUnit(), Task.CurrentLandingZoneName ) then
else
Task.ExecuteStage = _TransportExecuteStage.FAILED
Task:RemoveCargoMenus( Client )
@@ -473,7 +473,7 @@ self:T()
return 1
end
if not Client:GetClientGroupUnit():inAir() then
if not Client:GetClientGroupDCSUnit():inAir() then
else
Task.ExecuteStage = _TransportExecuteStage.FAILED
Task:RemoveCargoMenus( Client )
@@ -578,7 +578,7 @@ self:T()
self:T( "Task.CurrentLandingZoneName = " .. Task.CurrentLandingZoneName )
if not Task.IsSlingLoad then
if not routines.IsUnitInZones( Client:GetClientGroupUnit(), Task.CurrentLandingZoneName ) then
if not routines.IsUnitInZones( Client:GetClientGroupDCSUnit(), Task.CurrentLandingZoneName ) then
Task:RemoveCargoMenus( Client )
Task.ExecuteStage = _TransportExecuteStage.FAILED
Task.CargoName = nil
@@ -587,7 +587,7 @@ self:T()
return -1
end
if not Client:GetClientGroupUnit():inAir() then
if not Client:GetClientGroupDCSUnit():inAir() then
else
-- The carrier is back in the air, undo the loading process.
Task:RemoveCargoMenus( Client )
@@ -673,7 +673,7 @@ self:T()
function STAGEARRIVE:Validate( Mission, Client, Task )
self:T()
Task.CurrentLandingZoneID = routines.IsUnitInZones( Client:GetClientGroupUnit(), Task.LandingZones )
Task.CurrentLandingZoneID = routines.IsUnitInZones( Client:GetClientGroupDCSUnit(), Task.LandingZones )
if ( Task.CurrentLandingZoneID ) then
else
return -1

View File

@@ -12,27 +12,49 @@ UNIT = {
ClassName="UNIT",
}
function UNIT:New( _Unit )
function UNIT:New( DCSUnit )
local self = BASE:Inherit( self, BASE:New() )
self:T( _Unit:getName() )
self:T( DCSUnit:getName() )
self._Unit = _Unit
self.UnitName = _Unit:getName()
self.UnitID = _Unit:getID()
self.DCSUnit = DCSUnit
self.UnitName = DCSUnit:getName()
self.UnitID = DCSUnit:getID()
return self
end
function UNIT:IsAlive()
self:T( self.UnitName )
return ( self.DCSUnit and self.DCSUnit:isExist() )
end
function UNIT:GetCallSign()
self:T( self.UnitName )
return self._Unit:getCallsign()
return self.DCSUnit:getCallsign()
end
function UNIT:GetPoint()
self:T( self.UnitName )
local UnitPos = self.DCSUnit:getPosition().p
local UnitPoint = {}
UnitPoint.x = UnitPos.x
UnitPoint.y = UnitPos.z
self:T( UnitPoint )
return UnitPoint
end
function UNIT:GetPositionVec3()
self:T( self.UnitName )
local UnitPos = self._Unit:getPosition().p
local UnitPos = self.DCSUnit:getPosition().p
self:T( UnitPos )
return UnitPos

View File

@@ -30,6 +30,17 @@ trace.f( self.ClassName, ZoneName )
return self
end
function ZONE:GetPoint()
self:T( self.ZoneName )
local Zone = trigger.misc.getZone( self.ZoneName )
local Point = { x = Zone.point.x, y = Zone.point.z }
self:T( { Zone, Point } )
return Point
end
function ZONE:GetRandomPoint()
trace.f( self.ClassName, self.ZoneName )
@@ -55,3 +66,4 @@ trace.f( self.ClassName, self.ZoneName )
return Zone.radius
end