This commit is contained in:
Frank
2020-04-21 01:04:24 +02:00
parent 31697030ed
commit 11fb5500f3
11 changed files with 115 additions and 9044 deletions
File diff suppressed because it is too large Load Diff
+4 -7
View File
@@ -256,16 +256,13 @@ function DATABASE:AddAirbase( AirbaseName )
if not self.AIRBASES[AirbaseName] then if not self.AIRBASES[AirbaseName] then
-- Register airbase.
local airbase = AIRBASE:Register( AirbaseName ) --Wrapper.Airbase#AIRBASE local airbase = AIRBASE:Register( AirbaseName ) --Wrapper.Airbase#AIRBASE
-- Add to airbase.
self.AIRBASES[AirbaseName]=airbase self.AIRBASES[AirbaseName]=airbase
-- Category and name. -- Debug info
airbase.AirbaseCategory=airbase:GetAirbaseCategory()
airbase.AirbaseCategoryName=AIRBASE.CategoryName[airbase.AirbaseCategory]
-- Get airbase ID. WARNING: For ships it gets the unit ID. This can be identical to an exising AIRDROME or FARM ID! Therefore, units get a negative sign.
airbase.AirbaseID=airbase:GetID()
self:I(string.format("Adding airbase %s (ID=%d): %s with %d parking spots", tostring(airbase.AirbaseName), airbase.AirbaseID, airbase.AirbaseCategoryName, tonumber(#airbase.parking))) self:I(string.format("Adding airbase %s (ID=%d): %s with %d parking spots", tostring(airbase.AirbaseName), airbase.AirbaseID, airbase.AirbaseCategoryName, tonumber(#airbase.parking)))
end end
+1 -1
View File
@@ -1843,7 +1843,7 @@ function AIRWING:CanMission(Mission)
return false, Assets return false, Assets
end end
for squadname,_squadron in pairs(self.squadrons) do for squadname,_squadron in pairs(squadrons) do
local squadron=_squadron --Ops.Squadron#SQUADRON local squadron=_squadron --Ops.Squadron#SQUADRON
-- Check if this squadron can. -- Check if this squadron can.
+5 -1
View File
@@ -11946,9 +11946,13 @@ function AIRBOSS:_LSOgrade(playerData)
local nS=count(G, '%(') local nS=count(G, '%(')
local nN=N-nS-nL local nN=N-nS-nL
-- Groove time 16-18 sec for a unicorn.
local Tgroove=playerData.Tgroove
local TgrooveUnicorn=Tgroove and (Tgroove>=16.0 and Tgroove<=18.0) or false
local grade local grade
local points local points
if N==0 then if N==0 and TgrooveUnicorn then
-- No deviations, should be REALLY RARE! -- No deviations, should be REALLY RARE!
grade="_OK_" grade="_OK_"
points=5.0 points=5.0
+5 -1
View File
@@ -1305,8 +1305,12 @@ function AUFTRAG:AssignSquadrons(Squadrons)
Squadrons={Squadrons} Squadrons={Squadrons}
end end
self.squadrons=Squadrons for _,_squad in pairs(Squadrons) do
local squadron=_squad --Ops.Squadron#SQUADRON
self:I(self.lid..string.format("Assigning squadron %s", tostring(squadron.name)))
end
self.squadrons=Squadrons
end end
+58 -13
View File
@@ -56,6 +56,7 @@
-- @field #boolean passedfinalwp Group has passed the final waypoint. -- @field #boolean passedfinalwp Group has passed the final waypoint.
-- @field Ops.AirWing#AIRWING airwing The airwing the flight group belongs to. -- @field Ops.AirWing#AIRWING airwing The airwing the flight group belongs to.
-- @field Ops.FlightControl#FLIGHTCONTROL flightcontrol The flightcontrol handling this group. -- @field Ops.FlightControl#FLIGHTCONTROL flightcontrol The flightcontrol handling this group.
-- @field Ops.Airboss#AIRBOSS airboss The airboss handling this group.
-- @field Core.UserFlag#USERFLAG flaghold Flag for holding. -- @field Core.UserFlag#USERFLAG flaghold Flag for holding.
-- @field #number Tholding Abs. mission time stamp when the group reached the holding point. -- @field #number Tholding Abs. mission time stamp when the group reached the holding point.
-- @field #number Tparking Abs. mission time stamp when the group was spawned uncontrolled and is parking. -- @field #number Tparking Abs. mission time stamp when the group was spawned uncontrolled and is parking.
@@ -866,6 +867,15 @@ function FLIGHTGROUP:GetFlightControl()
return self.flightcontrol return self.flightcontrol
end end
--- Set the AIRBOSS controlling this flight group.
-- @param #FLIGHTGROUP self
-- @param Ops.Airboss#AIRBOSS airboss The AIRBOSS object.
-- @return #FLIGHTGROUP self
function FLIGHTGROUP:SetAirboss(airboss)
self.airboss=airboss
end
--- Set low fuel threshold. Triggers event "FuelLow" and calls event function "OnAfterFuelLow". --- Set low fuel threshold. Triggers event "FuelLow" and calls event function "OnAfterFuelLow".
-- @param #FLIGHTGROUP self -- @param #FLIGHTGROUP self
-- @param #number threshold Fuel threshold in percent. Default 25 %. -- @param #number threshold Fuel threshold in percent. Default 25 %.
@@ -2528,10 +2538,10 @@ end
-- @param #string From From state. -- @param #string From From state.
-- @param #string Event Event. -- @param #string Event Event.
-- @param #string To To state. -- @param #string To To state.
-- @param #number n Waypoint number. -- @param #number n Waypoint number. Default is next waypoint.
function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n) function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
-- TODO: what happens if currentwp=#waypoints -- Update route from this waypoint number onwards.
n=n or self.currentwp+1 n=n or self.currentwp+1
-- Update waypoint tasks, i.e. inject WP tasks into waypoint table. -- Update waypoint tasks, i.e. inject WP tasks into waypoint table.
@@ -2540,8 +2550,11 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
-- Waypoints. -- Waypoints.
local wp={} local wp={}
-- Current velocity.
local speed=self.group and self.group:GetVelocityKMH() or 100
-- Set current waypoint or we get problem that the _PassingWaypoint function is triggered too early, i.e. right now and not when passing the next WP. -- Set current waypoint or we get problem that the _PassingWaypoint function is triggered too early, i.e. right now and not when passing the next WP.
local current=self.group:GetCoordinate():WaypointAir(nil, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, 350, true, nil, {}, "Current") local current=self.group:GetCoordinate():WaypointAir("BARO", COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, speed, true, nil, {}, "Current")
table.insert(wp, current) table.insert(wp, current)
-- Add remaining waypoints to route. -- Add remaining waypoints to route.
@@ -2875,7 +2888,7 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp
self.flaghold:Set(0) self.flaghold:Set(0)
-- Task fuction when reached holding point. -- Task fuction when reached holding point.
local TaskArrived=self.group:TaskFunction("FLIGHTGROUP.", self) local TaskArrived=self.group:TaskFunction("FLIGHTGROUP._ReachedHolding", self)
-- Orbit until flaghold=1 (true) but max 5 min if no FC is giving the landing clearance. -- Orbit until flaghold=1 (true) but max 5 min if no FC is giving the landing clearance.
local TaskOrbit=self.group:TaskOrbit(p0, nil, UTILS.KnotsToMps(SpeedHold), p1) local TaskOrbit=self.group:TaskOrbit(p0, nil, UTILS.KnotsToMps(SpeedHold), p1)
@@ -2913,17 +2926,22 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp
end end
-- Respawn? local routeto=false
if fc or world.event.S_EVENT_KILL then if fc or world.event.S_EVENT_KILL then
routeto=true
end
self:T(self.lid.."FF route (not repawn)") -- Respawn?
if routeto then
self:I(self.lid.."FF route (not repawn)")
-- Just route the group. Respawn might happen when going from holding to final. -- Just route the group. Respawn might happen when going from holding to final.
self:Route(wp, 1) self:Route(wp, 1)
else else
self:T(self.lid.."FF respawn (not route)") self:I(self.lid.."FF respawn (not route)")
-- Get group template. -- Get group template.
local Template=self.group:GetTemplate() local Template=self.group:GetTemplate()
@@ -3089,6 +3107,7 @@ function FLIGHTGROUP:onafterHolding(From, Event, To)
if not self.ai then if not self.ai then
self:_UpdateMenu() self:_UpdateMenu()
end end
end end
end end
@@ -3553,7 +3572,7 @@ function FLIGHTGROUP:onafterTaskCancel(From, Event, To, Task)
if Task.type==FLIGHTGROUP.TaskType.WAYPOINT and Task.waypoint then if Task.type==FLIGHTGROUP.TaskType.WAYPOINT and Task.waypoint then
-- Check that this is a mission waypoint and no other tasks are defined here. -- Check that this is a mission waypoint and no other tasks are defined here.
if mission and #self:GetTasksWaypoint(Task.waypoint) then if mission and #self:GetTasksWaypoint(Task.waypoint)==0 then
self:RemoveWaypoint(Task.waypoint) self:RemoveWaypoint(Task.waypoint)
end end
end end
@@ -3901,7 +3920,7 @@ end
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Function called when a task is executed. --- Function called when a task is executed.
--@param Wrapper.Group#GROUP group Group that reached the holding zone. --@param Wrapper.Group#GROUP group Group which should execute the task.
--@param #FLIGHTGROUP flightgroup Flight group. --@param #FLIGHTGROUP flightgroup Flight group.
--@param #FLIGHTGROUP.Task task Task. --@param #FLIGHTGROUP.Task task Task.
function FLIGHTGROUP._TaskExecute(group, flightgroup, task) function FLIGHTGROUP._TaskExecute(group, flightgroup, task)
@@ -3917,7 +3936,7 @@ function FLIGHTGROUP._TaskExecute(group, flightgroup, task)
end end
--- Function called when a task is done. --- Function called when a task is done.
--@param Wrapper.Group#GROUP group Group that reached the holding zone. --@param Wrapper.Group#GROUP group Group for which the task is done.
--@param #FLIGHTGROUP flightgroup Flight group. --@param #FLIGHTGROUP flightgroup Flight group.
--@param #FLIGHTGROUP.Task task Task. --@param #FLIGHTGROUP.Task task Task.
function FLIGHTGROUP._TaskDone(group, flightgroup, task) function FLIGHTGROUP._TaskDone(group, flightgroup, task)
@@ -4636,9 +4655,17 @@ function FLIGHTGROUP:RemoveWaypoint(wpindex)
if self.waypoints then if self.waypoints then
-- Number of waypoints before delete.
local N=#self.waypoints
-- Remove waypoint. -- Remove waypoint.
table.remove(self.waypoints, wpindex) table.remove(self.waypoints, wpindex)
-- Number of waypoints after delete.
local n=#self.waypoints
self:I(self.lid..string.format("Removing waypoint %d. N %d-->%d", wpindex, N, n))
-- Shift all waypoint tasks after the removed waypoint. -- Shift all waypoint tasks after the removed waypoint.
for _,_task in pairs(self.taskqueue) do for _,_task in pairs(self.taskqueue) do
local task=_task --#FLIGHTGROUP.Task local task=_task --#FLIGHTGROUP.Task
@@ -4650,15 +4677,33 @@ function FLIGHTGROUP:RemoveWaypoint(wpindex)
-- Shift all mission waypoints after the removerd waypoint. -- Shift all mission waypoints after the removerd waypoint.
for _,_mission in pairs(self.missionqueue) do for _,_mission in pairs(self.missionqueue) do
local mission=_mission --Ops.Auftrag#AUFTRAG local mission=_mission --Ops.Auftrag#AUFTRAG
-- TODO: This is not the waypoint index any more. Waypoint index is now for each FLIGHTGROUP.
if mission.waypointindex and mission.waypointindex>wpindex then if mission.waypointindex and mission.waypointindex>wpindex then
mission.waypointindex=mission.waypointindex-1 mission.waypointindex=mission.waypointindex-1
end end
end end
--TODO update route?
-- no, if <= self.currentwaypoint or WP is landing.
self:__UpdateRoute(-1) -- Waypoint was not reached yet.
if wpindex > self.currentwp then
-- Could be that we just removed the only remaining waypoint ==> passedfinalwp=true so we RTB or wait.
if self.currentwp>=n then
self.passedfinalwp=true
end
env.info("FF update route -1 after waypoint removed")
self:_CheckFlightDone()
else
-- If an already passed waypoint was deleted, we do not need to update the route.
-- TODO: But what about the self.currentwp number. This is now incorrect!
self.currentwp=self.currentwp-1
end
end end
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+15 -9
View File
@@ -127,6 +127,9 @@ function SQUADRON:New(TemplateGroupName, Ngroups, SquadronName)
self.Ngroups=Ngroups or 3 self.Ngroups=Ngroups or 3
self:SetEngagementRange() self:SetEngagementRange()
-- Everyone can ORBIT.
self:AddMissonCapability(AUFTRAG.Type.ORBIT)
self.attribute=self.templategroup:GetAttribute() self.attribute=self.templategroup:GetAttribute()
self.aircrafttype=self.templategroup:GetTypeName() self.aircrafttype=self.templategroup:GetTypeName()
@@ -237,19 +240,22 @@ function SQUADRON:AddMissonCapability(MissionTypes, Performance)
MissionTypes={MissionTypes} MissionTypes={MissionTypes}
end end
-- Add ORBIT for all.
if not self:CheckMissionType(AUFTRAG.Type.ORBIT, MissionTypes) then
--table.insert(MissionTypes, AUFTRAG.Type.ORBIT)
end
-- Set table. -- Set table.
self.missiontypes=self.missiontypes or {} self.missiontypes=self.missiontypes or {}
for _,missiontype in pairs(MissionTypes) do for _,missiontype in pairs(MissionTypes) do
local capability={} --Ops.Auftrag#AUFTRAG.Capability
capability.MissionType=missiontype -- Check not to add the same twice.
capability.Performance=Performance or 50 if self:CheckMissionCapability(missiontype, self.missiontypes) then
table.insert(self.missiontypes, capability) self:E(self.lid.."WARNING: Mission capability already present! No need to add it twice.")
else
local capability={} --Ops.Auftrag#AUFTRAG.Capability
capability.MissionType=missiontype
capability.Performance=Performance or 50
table.insert(self.missiontypes, capability)
end
end end
-- Debug info. -- Debug info.
+26 -10
View File
@@ -377,9 +377,33 @@ AIRBASE.TerminalType = {
function AIRBASE:Register( AirbaseName ) function AIRBASE:Register( AirbaseName )
local self = BASE:Inherit( self, POSITIONABLE:New( AirbaseName ) ) --#AIRBASE local self = BASE:Inherit( self, POSITIONABLE:New( AirbaseName ) ) --#AIRBASE
-- Airbase name.
self.AirbaseName = AirbaseName self.AirbaseName = AirbaseName
-- Airbase unique ID.
self.AirbaseID = self:GetID(true) self.AirbaseID = self:GetID(true)
self.AirbaseZone = ZONE_RADIUS:New( AirbaseName, self:GetVec2(), 2500 )
-- Airbase category.
local desc=self:GetDesc()
local category=Airbase.Category.AIRDROME
if desc and desc.category then
category=desc.category
else
self:E(string.format("ERROR: Cannot get category of airbase %s due to DCS 2.5.6 bug! Assuming it is an AIRDROME for now...", tostring(self.AirbaseName)))
end
self.AirbaseCategory=category
-- Category name.
self.AirbaseCategoryName=AIRBASE.CategoryName[self.AirbaseCategory]
-- Airbase zone.
if self.AirbaseCategory==Airbase.Category.SHIP then
local unit=UNIT:FindByName(AirbaseName)
self.AirbaseZone = ZONE_UNIT:New(AirbaseName, unit, 2500)
else
self.AirbaseZone = ZONE_RADIUS:New( AirbaseName, self:GetVec2(), 2500 )
end
-- Get Parking data. -- Get Parking data.
self.parking=self:GetParkingSpotsTable() self.parking=self:GetParkingSpotsTable()
@@ -1112,15 +1136,7 @@ end
-- @param #AIRBASE self -- @param #AIRBASE self
-- @return #number Category of airbase from GetDesc().category. -- @return #number Category of airbase from GetDesc().category.
function AIRBASE:GetAirbaseCategory() function AIRBASE:GetAirbaseCategory()
local desc=self:GetDesc() return self.AirbaseCategory
local category=Airbase.Category.AIRDROME
if desc and desc.category then
category=desc.category
else
self:E(string.format("ERROR: Cannot get category of airbase %s due to DCS 2.5.6 bug! Assuming it is an AIRDROME for now...", tostring(self.AirbaseName)))
end
return category
end end