This commit is contained in:
Frank
2020-03-17 23:44:06 +01:00
parent 8823b96b5f
commit 1371445e94
6 changed files with 72 additions and 33 deletions
@@ -2589,6 +2589,34 @@ function WAREHOUSE:SetAutoDefenceOff()
return self return self
end end
--- Set valid parking spot IDs.
-- @param #WAREHOUSE self
-- @param #table ParkingIDs Table of numbers.
-- @return #WAREHOUSE self
function WAREHOUSE:SetParkingIDs(ParkingIDs)
self.parkingIDs=ParkingIDs
return self
end
--- Check parking ID.
-- @param #WAREHOUSE self
-- @param Wrapper.Airbase#AIRBASE.ParkingSpot spot Parking spot.
-- @return #boolean If true, parking is valid.
function WAREHOUSE:_CheckParkingValid(spot)
if self.parkingIDs==nil then
return true
end
for _,id in pairs(self.parkingIDs or {}) do
if spot.TerminalID==id then
return true
end
end
return false
end
--- Enable auto save of warehouse assets at mission end event. --- Enable auto save of warehouse assets at mission end event.
-- @param #WAREHOUSE self -- @param #WAREHOUSE self
-- @param #string path Path where to save the asset data file. -- @param #string path Path where to save the asset data file.
@@ -7500,7 +7528,7 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets)
local parkingspot=_parkingspot --Wrapper.Airbase#AIRBASE.ParkingSpot local parkingspot=_parkingspot --Wrapper.Airbase#AIRBASE.ParkingSpot
-- Check correct terminal type for asset. We don't want helos in shelters etc. -- Check correct terminal type for asset. We don't want helos in shelters etc.
if AIRBASE._CheckTerminalType(parkingspot.TerminalType, terminaltype) then if AIRBASE._CheckTerminalType(parkingspot.TerminalType, terminaltype) and self:_CheckParkingValid(parkingspot) then
-- Coordinate of the parking spot. -- Coordinate of the parking spot.
local _spot=parkingspot.Coordinate -- Core.Point#COORDINATE local _spot=parkingspot.Coordinate -- Core.Point#COORDINATE
+13 -16
View File
@@ -453,19 +453,19 @@ end
--- Create a new generic patrol point. --- Create a new generic patrol point.
-- @param #AIRWING self -- @param #AIRWING self
-- @param Core.Point#COORDINATE Coordinate Coordinate of the patrol point. -- @param Core.Point#COORDINATE Coordinate Coordinate of the patrol point. Default 10-15 NM away from the location of the airwing.
-- @param #number Heading Heading in degrees. -- @param #number Heading Heading in degrees. Default random (0, 360] degrees.
-- @param #number LegLength Length of race-track orbit in NM. -- @param #number LegLength Length of race-track orbit in NM. Default 15 NM.
-- @param #number Altitude Orbit altitude in feet. -- @param #number Altitude Orbit altitude in feet. Default random between Angels 10 and 20.
-- @param #number Speed Orbit speed in knots. -- @param #number Speed Orbit speed in knots. Default 350 knots.
-- @return #AIRWING.PatrolData Patrol point table. -- @return #AIRWING.PatrolData Patrol point table.
function AIRWING:NewPatrolPoint(Coordinate, Heading, LegLength, Altitude, Speed) function AIRWING:NewPatrolPoint(Coordinate, Heading, LegLength, Altitude, Speed)
local cappoint={} --#AIRWING.PatrolData local cappoint={} --#AIRWING.PatrolData
cappoint.coord=Coordinate cappoint.coord=Coordinate or self:GetCoordinate():Translate(UTILS.NMToMeters(math.random(10, 15)), math.random(360))
cappoint.heading=Heading or 090 cappoint.heading=Heading or math.random(360)
cappoint.leg=LegLength or 15 cappoint.leg=LegLength or 15
cappoint.altitude=Altitude cappoint.altitude=Altitude or math.random(10,20)*1000
cappoint.speed=Speed or 350 cappoint.speed=Speed or 350
cappoint.noccupied=0 cappoint.noccupied=0
@@ -627,15 +627,8 @@ function AIRWING:_GetPatrolData(PatrolPoints)
return PatrolPoints[1] return PatrolPoints[1]
else else
local Coordinate=self:GetCoordinate()
local Heading=math.random(360)
local LegLength=math.random(10, 15)
local Altitude=math.random(10,15)*1000
local Speed=math.random(250, 350)
return self:NewPatrolPoint(Coordinate, Heading, LegLength, Altitude, Speed) return self:NewPatrolPoint()
end end
@@ -695,6 +688,8 @@ function AIRWING:CheckTANKER()
local patrol=self:_GetPatrolData(self.pointsTANKER) local patrol=self:_GetPatrolData(self.pointsTANKER)
patrol.coord:MarkToAll("Patrol point boom")
local mission=AUFTRAG:NewTANKER(patrol.coord, patrol.speed, patrol.heading, patrol.leg, patrol.altitude, 0) local mission=AUFTRAG:NewTANKER(patrol.coord, patrol.speed, patrol.heading, patrol.leg, patrol.altitude, 0)
mission.patroldata=patrol mission.patroldata=patrol
@@ -709,6 +704,8 @@ function AIRWING:CheckTANKER()
local patrol=self:_GetPatrolData(self.pointsTANKER) local patrol=self:_GetPatrolData(self.pointsTANKER)
patrol.coord:MarkToAll("Patrol point probe")
local mission=AUFTRAG:NewTANKER(patrol.coord, patrol.speed, patrol.heading, patrol.leg, patrol.altitude, 1) local mission=AUFTRAG:NewTANKER(patrol.coord, patrol.speed, patrol.heading, patrol.leg, patrol.altitude, 1)
mission.patroldata=patrol mission.patroldata=patrol
+3 -1
View File
@@ -356,6 +356,8 @@ function AUFTRAG:NewORBIT(Coordinate, Speed, Heading, Leg, Altitude)
end end
auftrag.missionAltitude=auftrag.orbitCoord.y*0.9 auftrag.missionAltitude=auftrag.orbitCoord.y*0.9
auftrag.missionFraction=0.9
auftrag.DCStask=auftrag:GetDCSMissionTask() auftrag.DCStask=auftrag:GetDCSMissionTask()
@@ -602,7 +604,7 @@ end
-- @param Wrapper.Group#GROUP EscortGroup The group to escort. -- @param Wrapper.Group#GROUP EscortGroup The group to escort.
-- @param DCS#Vec3 OffsetVector A table with x, y and z components specifying the offset of the flight to the escorted group. Default {x=200, y=0, z=-100} for 200 meters to the right, same alitude, 100 meters behind. -- @param DCS#Vec3 OffsetVector A table with x, y and z components specifying the offset of the flight to the escorted group. Default {x=200, y=0, z=-100} for 200 meters to the right, same alitude, 100 meters behind.
-- @param #number EngageMaxDistance Max engage distance of targets in meters. Default auto (*nil*). -- @param #number EngageMaxDistance Max engage distance of targets in meters. Default auto (*nil*).
-- @param #table TargetTypes Types of targets to engage automatically. Default is {"Air"}, i.e. all enemy airborne units. -- @param #table TargetTypes Types of targets to engage automatically. Default is {"Air"}, i.e. all enemy airborne units. Set to {} for a simple "FOLLOW" mission.
-- @return #AUFTRAG self -- @return #AUFTRAG self
function AUFTRAG:NewESCORT(EscortGroup, OffsetVector, EngageMaxDistance, TargetTypes) function AUFTRAG:NewESCORT(EscortGroup, OffsetVector, EngageMaxDistance, TargetTypes)
+2 -2
View File
@@ -3495,7 +3495,7 @@ function FLIGHTGROUP:RouteToMission(mission, delay)
end end
-- Add enroute tasks. -- Add enroute tasks.
for _,task in mission.enrouteTasks do for _,task in pairs(mission.enrouteTasks) do
self:AddTaskEnroute(task) self:AddTaskEnroute(task)
end end
@@ -3503,7 +3503,7 @@ function FLIGHTGROUP:RouteToMission(mission, delay)
local speed=UTILS.KmphToKnots(math.min(self.speedmax*0.8, 1000)) local speed=UTILS.KmphToKnots(math.min(self.speedmax*0.8, 1000))
-- Add waypoint. -- Add waypoint.
self:AddWaypointAir(waypointcoord, nextwaypoint, self.speedmax*0.8, false) self:AddWaypointAir(waypointcoord, nextwaypoint, speed, false)
-- Add waypoint task. UpdateRoute is called inside. -- Add waypoint task. UpdateRoute is called inside.
local waypointtask=self:AddTaskWaypoint(mission.DCStask, nextwaypoint, mission.name, mission.prio, mission.duration) local waypointtask=self:AddTaskWaypoint(mission.DCStask, nextwaypoint, mission.name, mission.prio, mission.duration)
+17 -6
View File
@@ -27,7 +27,8 @@
-- @field #number Ngroups Number of asset flight groups this squadron has. -- @field #number Ngroups Number of asset flight groups this squadron has.
-- @field #number engageRange Engagement range in meters. -- @field #number engageRange Engagement range in meters.
-- @field #string attribute Generalized attribute of the squadron template group. -- @field #string attribute Generalized attribute of the squadron template group.
-- @field #number refuelSystem For tanker squads, the refuel system used. -- @field #number tankerSystem For tanker squads, the refuel system used (boom=0 or probpe=1). Default nil.
-- @field #number refuelSystem For refuelable squads, the refuel system used (boom=0 or probpe=1). Default nil.
-- @extends Core.Fsm#FSM -- @extends Core.Fsm#FSM
--- Be surprised! --- Be surprised!
@@ -54,6 +55,7 @@ SQUADRON = {
airwing = nil, airwing = nil,
Ngroups = nil, Ngroups = nil,
engageRange = nil, engageRange = nil,
tankerSystem = nil,
refuelSystem = nil, refuelSystem = nil,
} }
@@ -70,7 +72,7 @@ SQUADRON.version="0.0.3"
-- TODO list -- TODO list
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO: Engage radius. -- DONE: Engage radius.
-- TODO: Modex. -- TODO: Modex.
-- TODO: Call signs. -- TODO: Call signs.
@@ -114,7 +116,8 @@ function SQUADRON:New(TemplateGroupName, Ngroups, SquadronName)
self.attribute=self.templategroup:GetAttribute() self.attribute=self.templategroup:GetAttribute()
_,self.refuelSystem=self.templategroup:GetUnit(1):IsTanker() _,self.refuelSystem=self.templategroup:GetUnit(1):IsRefuelable()
_,self.tankerSystem=self.templategroup:GetUnit(1):IsTanker()
-- Start State. -- Start State.
@@ -216,12 +219,19 @@ function SQUADRON:SetMissonTypes(MissionTypes)
return self return self
end end
--- Get mission types this squadron is able to perform.
-- @param #SQUADRON self
-- @param #table MissionTypes Table of mission types.
function SQUADRON:GetMissonTypes()
return self.missiontypes
end
--- Set max engagement range. --- Set max engagement range.
-- @param #SQUADRON self -- @param #SQUADRON self
-- @param #number EngageRange Engagement range in NM. Default 250 NM. -- @param #number EngageRange Engagement range in NM. Default 80 NM.
-- @return #SQUADRON self -- @return #SQUADRON self
function SQUADRON:SetEngagementRange(EngageRange) function SQUADRON:SetEngagementRange(EngageRange)
self.engageRange=UTILS.NMToMeters(EngageRange or 250) self.engageRange=UTILS.NMToMeters(EngageRange or 80)
return self return self
end end
@@ -334,9 +344,10 @@ function SQUADRON:CanMission(Mission)
-- Check that tanker mission -- Check that tanker mission
if cando and Mission.type==AUFTRAG.Type.TANKER then if cando and Mission.type==AUFTRAG.Type.TANKER then
if Mission.refuelSystem and Mission.refuelSystem==self.refuelSystem then if Mission.refuelSystem and Mission.refuelSystem==self.tankerSystem then
-- Correct refueling system. -- Correct refueling system.
else else
env.info(string.format("wrong refuling system mi=%s ta=%s", tostring(Mission.refuelSystem), tostring(self.tankerSystem)))
cando=false cando=false
end end
+8 -7
View File
@@ -447,7 +447,7 @@ function UNIT:IsRefuelable()
local system=nil local system=nil
local Desc=self:GetDesc().attributes local Desc=self:GetDesc()
if Desc and Desc.tankerType then if Desc and Desc.tankerType then
system=Desc.tankerType system=Desc.tankerType
end end
@@ -466,25 +466,26 @@ function UNIT:IsTanker()
local system=nil local system=nil
local Desc=self:GetDesc().attributes local Desc=self:GetDesc()
if Desc and Desc.tankerType then if Desc and Desc.tankerType then
system=Desc.tankerType system=Desc.tankerType
end end
local typename=self:GetTypeName() local typename=self:GetTypeName()
if typename=="IL-78M" then if typename=="IL-78M" then
system=1 --probe system=1 --probe
elseif typename=="KC130" then elseif typename=="KC130" then
system=-1 --? system=1 --probe
elseif typename=="KC135BDA" then elseif typename=="KC135BDA" then
system=-1 --? system=1 --probe
elseif typename=="KC135BDA" then
system=-1 --?
elseif typename=="KC135MPRS" then elseif typename=="KC135MPRS" then
system=0 --boom system=1 --probe
elseif typename=="S-3B Tanker" then elseif typename=="S-3B Tanker" then
system=1 --probe system=1 --probe
end end
env.info(string.format("unit %s type=%s: tanker=%s system=%s", tostring(self.UnitName), tostring(typename), tostring(tanker), tostring(system)))
return tanker, system return tanker, system
end end