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
-- Register airbase.
local airbase = AIRBASE:Register( AirbaseName ) --Wrapper.Airbase#AIRBASE
-- Add to airbase.
self.AIRBASES[AirbaseName]=airbase
-- Category and name.
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()
-- Debug info
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
+1 -1
View File
@@ -1843,7 +1843,7 @@ function AIRWING:CanMission(Mission)
return false, Assets
end
for squadname,_squadron in pairs(self.squadrons) do
for squadname,_squadron in pairs(squadrons) do
local squadron=_squadron --Ops.Squadron#SQUADRON
-- Check if this squadron can.
+5 -1
View File
@@ -11946,9 +11946,13 @@ function AIRBOSS:_LSOgrade(playerData)
local nS=count(G, '%(')
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 points
if N==0 then
if N==0 and TgrooveUnicorn then
-- No deviations, should be REALLY RARE!
grade="_OK_"
points=5.0
+5 -1
View File
@@ -1304,9 +1304,13 @@ function AUFTRAG:AssignSquadrons(Squadrons)
if Squadrons:IsInstanceOf("SQUADRON") then
Squadrons={Squadrons}
end
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
+59 -14
View File
@@ -56,6 +56,7 @@
-- @field #boolean passedfinalwp Group has passed the final waypoint.
-- @field Ops.AirWing#AIRWING airwing The airwing the flight group belongs to.
-- @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 #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.
@@ -866,6 +867,15 @@ function FLIGHTGROUP:GetFlightControl()
return self.flightcontrol
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".
-- @param #FLIGHTGROUP self
-- @param #number threshold Fuel threshold in percent. Default 25 %.
@@ -2528,10 +2538,10 @@ end
-- @param #string From From state.
-- @param #string Event Event.
-- @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)
-- TODO: what happens if currentwp=#waypoints
-- Update route from this waypoint number onwards.
n=n or self.currentwp+1
-- Update waypoint tasks, i.e. inject WP tasks into waypoint table.
@@ -2540,8 +2550,11 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
-- Waypoints.
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.
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)
-- Add remaining waypoints to route.
@@ -2875,7 +2888,7 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp
self.flaghold:Set(0)
-- 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.
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
-- Respawn?
local routeto=false
if fc or world.event.S_EVENT_KILL then
routeto=true
end
-- Respawn?
if routeto then
self:T(self.lid.."FF route (not repawn)")
self:I(self.lid.."FF route (not repawn)")
-- Just route the group. Respawn might happen when going from holding to final.
self:Route(wp, 1)
else
self:T(self.lid.."FF respawn (not route)")
self:I(self.lid.."FF respawn (not route)")
-- Get group template.
local Template=self.group:GetTemplate()
@@ -3089,6 +3107,7 @@ function FLIGHTGROUP:onafterHolding(From, Event, To)
if not self.ai then
self:_UpdateMenu()
end
end
end
@@ -3553,7 +3572,7 @@ function FLIGHTGROUP:onafterTaskCancel(From, Event, To, Task)
if Task.type==FLIGHTGROUP.TaskType.WAYPOINT and Task.waypoint then
-- 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)
end
end
@@ -3901,7 +3920,7 @@ end
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- 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.Task task Task.
function FLIGHTGROUP._TaskExecute(group, flightgroup, task)
@@ -3917,7 +3936,7 @@ function FLIGHTGROUP._TaskExecute(group, flightgroup, task)
end
--- 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.Task task Task.
function FLIGHTGROUP._TaskDone(group, flightgroup, task)
@@ -4635,9 +4654,17 @@ end
function FLIGHTGROUP:RemoveWaypoint(wpindex)
if self.waypoints then
-- Number of waypoints before delete.
local N=#self.waypoints
-- Remove waypoint.
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.
for _,_task in pairs(self.taskqueue) do
@@ -4650,16 +4677,34 @@ function FLIGHTGROUP:RemoveWaypoint(wpindex)
-- Shift all mission waypoints after the removerd waypoint.
for _,_mission in pairs(self.missionqueue) do
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
mission.waypointindex=mission.waypointindex-1
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:SetEngagementRange()
-- Everyone can ORBIT.
self:AddMissonCapability(AUFTRAG.Type.ORBIT)
self.attribute=self.templategroup:GetAttribute()
self.aircrafttype=self.templategroup:GetTypeName()
@@ -237,19 +240,22 @@ function SQUADRON:AddMissonCapability(MissionTypes, Performance)
MissionTypes={MissionTypes}
end
-- Add ORBIT for all.
if not self:CheckMissionType(AUFTRAG.Type.ORBIT, MissionTypes) then
--table.insert(MissionTypes, AUFTRAG.Type.ORBIT)
end
-- Set table.
self.missiontypes=self.missiontypes or {}
for _,missiontype in pairs(MissionTypes) do
local capability={} --Ops.Auftrag#AUFTRAG.Capability
capability.MissionType=missiontype
capability.Performance=Performance or 50
table.insert(self.missiontypes, capability)
-- Check not to add the same twice.
if self:CheckMissionCapability(missiontype, self.missiontypes) then
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
-- Debug info.
+26 -10
View File
@@ -377,9 +377,33 @@ AIRBASE.TerminalType = {
function AIRBASE:Register( AirbaseName )
local self = BASE:Inherit( self, POSITIONABLE:New( AirbaseName ) ) --#AIRBASE
-- Airbase name.
self.AirbaseName = AirbaseName
-- Airbase unique ID.
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.
self.parking=self:GetParkingSpotsTable()
@@ -1112,15 +1136,7 @@ end
-- @param #AIRBASE self
-- @return #number Category of airbase from GetDesc().category.
function AIRBASE:GetAirbaseCategory()
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
return category
return self.AirbaseCategory
end