mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf61f22dd1 | ||
|
|
5e8a36802c | ||
|
|
b34b537a26 | ||
|
|
812fb99e66 | ||
|
|
9cb3111dd5 | ||
|
|
1312555690 | ||
|
|
aa4f8452fa | ||
|
|
e2c1097ec5 |
@@ -2774,7 +2774,7 @@ do -- AI_A2A_DISPATCHER
|
||||
-- A2ADispatcher = AI_A2A_DISPATCHER:New( Detection )
|
||||
--
|
||||
-- -- Now Setup the default fuel treshold.
|
||||
-- A2ADispatcher:SetSquadronRefuelThreshold( "SquadronName", 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank.
|
||||
-- A2ADispatcher:SetSquadronFuelThreshold( "SquadronName", 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank.
|
||||
--
|
||||
function AI_A2A_DISPATCHER:SetSquadronFuelThreshold( SquadronName, FuelThreshold )
|
||||
|
||||
@@ -2817,7 +2817,7 @@ do -- AI_A2A_DISPATCHER
|
||||
-- A2ADispatcher = AI_A2A_DISPATCHER:New( Detection )
|
||||
--
|
||||
-- -- Now Setup the squadron fuel treshold.
|
||||
-- A2ADispatcher:SetSquadronRefuelThreshold( "SquadronName", 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank.
|
||||
-- A2ADispatcher:SetSquadronFuelThreshold( "SquadronName", 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank.
|
||||
--
|
||||
-- -- Now Setup the squadron tanker.
|
||||
-- A2ADispatcher:SetSquadronTanker( "SquadronName", "Tanker" ) -- The group name of the tanker is "Tanker" in the Mission Editor.
|
||||
|
||||
@@ -184,11 +184,13 @@ function AI_FORMATION:New( FollowUnit, FollowGroupSet, FollowName, FollowBriefin
|
||||
|
||||
self.FollowGroupSet:ForEachGroup(
|
||||
function( FollowGroup )
|
||||
self:E("Following")
|
||||
--self:E("Following")
|
||||
FollowGroup:SetState( self, "Mode", self.__Enum.Mode.Formation )
|
||||
end
|
||||
)
|
||||
|
||||
self:SetFlightModeFormation()
|
||||
|
||||
self:SetFlightRandomization( 2 )
|
||||
|
||||
self:SetStartState( "None" )
|
||||
@@ -997,7 +999,7 @@ function AI_FORMATION:SetFlightModeMission( FollowGroup )
|
||||
FollowGroup:SetState( FollowGroup, "PreviousMode", FollowGroup:GetState( FollowGroup, "Mode" ) )
|
||||
FollowGroup:SetState( FollowGroup, "Mode", self.__Enum.Mode.Mission )
|
||||
else
|
||||
self.EscortGroupSet:ForSomeGroupAlive(
|
||||
self.FollowGroupSet:ForSomeGroupAlive(
|
||||
--- @param Core.Group#GROUP EscortGroup
|
||||
function( FollowGroup )
|
||||
FollowGroup:SetState( FollowGroup, "PreviousMode", FollowGroup:GetState( FollowGroup, "Mode" ) )
|
||||
@@ -1021,7 +1023,7 @@ function AI_FORMATION:SetFlightModeAttack( FollowGroup )
|
||||
FollowGroup:SetState( FollowGroup, "PreviousMode", FollowGroup:GetState( FollowGroup, "Mode" ) )
|
||||
FollowGroup:SetState( FollowGroup, "Mode", self.__Enum.Mode.Attack )
|
||||
else
|
||||
self.EscortGroupSet:ForSomeGroupAlive(
|
||||
self.FollowGroupSet:ForSomeGroupAlive(
|
||||
--- @param Core.Group#GROUP EscortGroup
|
||||
function( FollowGroup )
|
||||
FollowGroup:SetState( FollowGroup, "PreviousMode", FollowGroup:GetState( FollowGroup, "Mode" ) )
|
||||
@@ -1045,7 +1047,7 @@ function AI_FORMATION:SetFlightModeFormation( FollowGroup )
|
||||
FollowGroup:SetState( FollowGroup, "PreviousMode", FollowGroup:GetState( FollowGroup, "Mode" ) )
|
||||
FollowGroup:SetState( FollowGroup, "Mode", self.__Enum.Mode.Formation )
|
||||
else
|
||||
self.EscortGroupSet:ForSomeGroupAlive(
|
||||
self.FollowGroupSet:ForSomeGroupAlive(
|
||||
--- @param Core.Group#GROUP EscortGroup
|
||||
function( FollowGroup )
|
||||
FollowGroup:SetState( FollowGroup, "PreviousMode", FollowGroup:GetState( FollowGroup, "Mode" ) )
|
||||
|
||||
@@ -451,23 +451,23 @@ do -- Event Handling
|
||||
|
||||
--- Subscribe to a DCS Event.
|
||||
-- @param #BASE self
|
||||
-- @param Core.Event#EVENTS Event
|
||||
-- @param Core.Event#EVENTS EventID Event ID.
|
||||
-- @param #function EventFunction (optional) The function to be called when the event occurs for the unit.
|
||||
-- @return #BASE
|
||||
function BASE:HandleEvent( Event, EventFunction )
|
||||
function BASE:HandleEvent( EventID, EventFunction )
|
||||
|
||||
self:EventDispatcher():OnEventGeneric( EventFunction, self, Event )
|
||||
self:EventDispatcher():OnEventGeneric( EventFunction, self, EventID )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- UnSubscribe to a DCS event.
|
||||
-- @param #BASE self
|
||||
-- @param Core.Event#EVENTS Event
|
||||
-- @param Core.Event#EVENTS EventID Event ID.
|
||||
-- @return #BASE
|
||||
function BASE:UnHandleEvent( Event )
|
||||
function BASE:UnHandleEvent( EventID )
|
||||
|
||||
self:EventDispatcher():RemoveEvent( self, Event )
|
||||
self:EventDispatcher():RemoveEvent( self, EventID )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -526,17 +526,21 @@ local _EVENTMETA = {
|
||||
-- @param #EVENT self
|
||||
-- @return #EVENT self
|
||||
function EVENT:New()
|
||||
|
||||
-- Inherit base.
|
||||
local self = BASE:Inherit( self, BASE:New() )
|
||||
self:F2()
|
||||
self.EventHandler = world.addEventHandler( self )
|
||||
|
||||
-- Add world event handler.
|
||||
self.EventHandler = world.addEventHandler(self)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Initializes the Events structure for the event
|
||||
--- Initializes the Events structure for the event.
|
||||
-- @param #EVENT self
|
||||
-- @param DCS#world.event EventID
|
||||
-- @param Core.Base#BASE EventClass
|
||||
-- @param DCS#world.event EventID Event ID.
|
||||
-- @param Core.Base#BASE EventClass The class object for which events are handled.
|
||||
-- @return #EVENT.Events
|
||||
function EVENT:Init( EventID, EventClass )
|
||||
self:F3( { _EVENTMETA[EventID].Text, EventClass } )
|
||||
@@ -548,6 +552,7 @@ function EVENT:Init( EventID, EventClass )
|
||||
|
||||
-- Each event has a subtable of EventClasses, ordered by EventPriority.
|
||||
local EventPriority = EventClass:GetEventPriority()
|
||||
|
||||
if not self.Events[EventID][EventPriority] then
|
||||
self.Events[EventID][EventPriority] = setmetatable( {}, { __mode = "k" } )
|
||||
end
|
||||
@@ -555,40 +560,45 @@ function EVENT:Init( EventID, EventClass )
|
||||
if not self.Events[EventID][EventPriority][EventClass] then
|
||||
self.Events[EventID][EventPriority][EventClass] = {}
|
||||
end
|
||||
|
||||
|
||||
|
||||
return self.Events[EventID][EventPriority][EventClass]
|
||||
end
|
||||
|
||||
--- Removes a subscription
|
||||
-- @param #EVENT self
|
||||
-- @param Core.Base#BASE EventClass The self instance of the class for which the event is.
|
||||
-- @param DCS#world.event EventID
|
||||
-- @return #EVENT.Events
|
||||
-- @param DCS#world.event EventID Event ID.
|
||||
-- @return #EVENT self
|
||||
function EVENT:RemoveEvent( EventClass, EventID )
|
||||
|
||||
-- Debug info.
|
||||
self:F2( { "Removing subscription for class: ", EventClass:GetClassNameAndID() } )
|
||||
|
||||
-- Get event prio.
|
||||
local EventPriority = EventClass:GetEventPriority()
|
||||
|
||||
-- Events.
|
||||
self.Events = self.Events or {}
|
||||
self.Events[EventID] = self.Events[EventID] or {}
|
||||
self.Events[EventID][EventPriority] = self.Events[EventID][EventPriority] or {}
|
||||
|
||||
-- Remove
|
||||
self.Events[EventID][EventPriority][EventClass] = nil
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Resets subscriptions
|
||||
--- Resets subscriptions.
|
||||
-- @param #EVENT self
|
||||
-- @param Core.Base#BASE EventClass The self instance of the class for which the event is.
|
||||
-- @param DCS#world.event EventID
|
||||
-- @param DCS#world.event EventID Event ID.
|
||||
-- @return #EVENT.Events
|
||||
function EVENT:Reset( EventObject ) --R2.1
|
||||
|
||||
self:F( { "Resetting subscriptions for class: ", EventObject:GetClassNameAndID() } )
|
||||
|
||||
local EventPriority = EventObject:GetEventPriority()
|
||||
|
||||
for EventID, EventData in pairs( self.Events ) do
|
||||
if self.EventsDead then
|
||||
if self.EventsDead[EventID] then
|
||||
@@ -603,19 +613,22 @@ function EVENT:Reset( EventObject ) --R2.1
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--- Clears all event subscriptions for a @{Core.Base#BASE} derived object.
|
||||
-- @param #EVENT self
|
||||
-- @param Core.Base#BASE EventObject
|
||||
function EVENT:RemoveAll( EventObject )
|
||||
self:F3( { EventObject:GetClassNameAndID() } )
|
||||
-- @param Core.Base#BASE EventClass The self class object for which the events are removed.
|
||||
-- @return #EVENT self
|
||||
function EVENT:RemoveAll(EventClass)
|
||||
|
||||
local EventClass = EventObject:GetClassNameAndID()
|
||||
local EventClassName = EventClass:GetClassNameAndID()
|
||||
|
||||
-- Get Event prio.
|
||||
local EventPriority = EventClass:GetEventPriority()
|
||||
|
||||
for EventID, EventData in pairs( self.Events ) do
|
||||
self.Events[EventID][EventPriority][EventClass] = nil
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
@@ -636,7 +649,7 @@ function EVENT:OnEventForTemplate( EventTemplate, EventFunction, EventClass, Eve
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set a new listener for an S_EVENT_X event independent from a unit or a weapon.
|
||||
--- Set a new listener for an `S_EVENT_X` event independent from a unit or a weapon.
|
||||
-- @param #EVENT self
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param Core.Base#BASE EventClass The self instance of the class for which the event is captured. When the event happens, the event process will be called in this class provided.
|
||||
@@ -652,13 +665,13 @@ function EVENT:OnEventGeneric( EventFunction, EventClass, EventID )
|
||||
end
|
||||
|
||||
|
||||
--- Set a new listener for an S_EVENT_X event for a UNIT.
|
||||
--- Set a new listener for an `S_EVENT_X` event for a UNIT.
|
||||
-- @param #EVENT self
|
||||
-- @param #string UnitName The name of the UNIT.
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the GROUP.
|
||||
-- @param Core.Base#BASE EventClass The self instance of the class for which the event is.
|
||||
-- @param EventID
|
||||
-- @return #EVENT
|
||||
-- @return #EVENT self
|
||||
function EVENT:OnEventForUnit( UnitName, EventFunction, EventClass, EventID )
|
||||
self:F2( UnitName )
|
||||
|
||||
@@ -724,10 +737,10 @@ do -- OnDead
|
||||
|
||||
--- Create an OnDead event handler for a group
|
||||
-- @param #EVENT self
|
||||
-- @param Wrapper.Group#GROUP EventGroup
|
||||
-- @param Wrapper.Group#GROUP EventGroup The GROUP object.
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param EventClass The self instance of the class for which the event is.
|
||||
-- @return #EVENT
|
||||
-- @param #table EventClass The self instance of the class for which the event is.
|
||||
-- @return #EVENT self
|
||||
function EVENT:OnDeadForTemplate( EventTemplate, EventFunction, EventClass )
|
||||
self:F2( EventTemplate.name )
|
||||
|
||||
@@ -740,12 +753,13 @@ end
|
||||
|
||||
|
||||
do -- OnLand
|
||||
|
||||
--- Create an OnLand event handler for a group
|
||||
-- @param #EVENT self
|
||||
-- @param #table EventTemplate
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param EventClass The self instance of the class for which the event is.
|
||||
-- @return #EVENT
|
||||
-- @param #table EventClass The self instance of the class for which the event is.
|
||||
-- @return #EVENT self
|
||||
function EVENT:OnLandForTemplate( EventTemplate, EventFunction, EventClass )
|
||||
self:F2( EventTemplate.name )
|
||||
|
||||
@@ -757,12 +771,13 @@ do -- OnLand
|
||||
end
|
||||
|
||||
do -- OnTakeOff
|
||||
|
||||
--- Create an OnTakeOff event handler for a group
|
||||
-- @param #EVENT self
|
||||
-- @param #table EventTemplate
|
||||
-- @param #table EventTemplate Template table.
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param EventClass The self instance of the class for which the event is.
|
||||
-- @return #EVENT
|
||||
-- @param #table EventClass The self instance of the class for which the event is.
|
||||
-- @return #EVENT self
|
||||
function EVENT:OnTakeOffForTemplate( EventTemplate, EventFunction, EventClass )
|
||||
self:F2( EventTemplate.name )
|
||||
|
||||
@@ -902,8 +917,9 @@ do -- Event Creation
|
||||
|
||||
end
|
||||
|
||||
--- @param #EVENT self
|
||||
-- @param #EVENTDATA Event
|
||||
--- Main event function.
|
||||
-- @param #EVENT self
|
||||
-- @param #EVENTDATA Event Event data table.
|
||||
function EVENT:onEvent( Event )
|
||||
|
||||
local ErrorHandler = function( errmsg )
|
||||
@@ -1287,7 +1303,7 @@ function EVENT:onEvent( Event )
|
||||
Event = nil
|
||||
end
|
||||
|
||||
--- The EVENTHANDLER structure
|
||||
--- The EVENTHANDLER structure.
|
||||
-- @type EVENTHANDLER
|
||||
-- @extends Core.Base#BASE
|
||||
EVENTHANDLER = {
|
||||
@@ -1295,7 +1311,7 @@ EVENTHANDLER = {
|
||||
ClassID = 0,
|
||||
}
|
||||
|
||||
--- The EVENTHANDLER constructor
|
||||
--- The EVENTHANDLER constructor.
|
||||
-- @param #EVENTHANDLER self
|
||||
-- @return #EVENTHANDLER self
|
||||
function EVENTHANDLER:New()
|
||||
|
||||
@@ -525,7 +525,7 @@ end
|
||||
|
||||
--- Get unit from which we want to transmit a radio message. This has to be an aircraft for subtitles to work.
|
||||
-- @param #RADIOQUEUE self
|
||||
-- @return Wrapper.Unit#UNIT Sending aircraft unit or nil if was not setup, is not an aircraft or is not alive.
|
||||
-- @return Wrapper.Unit#UNIT Sending unit or nil if was not setup, is not an aircraft or ground unit or is not alive.
|
||||
function RADIOQUEUE:_GetRadioSender()
|
||||
|
||||
-- Check if we have a sending aircraft.
|
||||
@@ -538,7 +538,7 @@ function RADIOQUEUE:_GetRadioSender()
|
||||
sender=UNIT:FindByName(self.sendername)
|
||||
|
||||
-- Check that sender is alive and an aircraft.
|
||||
if sender and sender:IsAlive() and sender:IsAir() then
|
||||
if sender and sender:IsAlive() and (sender:IsAir() or sender:IsGround()) then
|
||||
return sender
|
||||
end
|
||||
|
||||
|
||||
@@ -341,7 +341,7 @@ do
|
||||
-- @return #SPOT
|
||||
function SPOT:onafterLaseOff( From, Event, To )
|
||||
|
||||
self:F( {"Stopped lasing for ", self.Target:GetName() , SpotIR = self.SportIR, SpotLaser = self.SpotLaser } )
|
||||
self:F( {"Stopped lasing for ", self.Target and self.Target:GetName() or "coord", SpotIR = self.SportIR, SpotLaser = self.SpotLaser } )
|
||||
|
||||
self.Lasing = false
|
||||
|
||||
|
||||
@@ -693,7 +693,7 @@ ARTY.db={
|
||||
|
||||
--- Arty script version.
|
||||
-- @field #string version
|
||||
ARTY.version="1.1.7"
|
||||
ARTY.version="1.1.8"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -2770,7 +2770,7 @@ function ARTY:onafterStatus(Controllable, From, Event, To)
|
||||
|
||||
-- FSM state.
|
||||
local fsmstate=self:GetState()
|
||||
self:I(self.lid..string.format("Status %s, Ammo total=%d: shells=%d [smoke=%d, illu=%d, nukes=%d*%.3f kT], rockets=%d, missiles=%d", fsmstate, ntot, nshells, self.Nsmoke, self.Nillu, self.Nukes, self.nukewarhead/1000000, nrockets, nmissiles))
|
||||
self:T(self.lid..string.format("Status %s, Ammo total=%d: shells=%d [smoke=%d, illu=%d, nukes=%d*%.3f kT], rockets=%d, missiles=%d", fsmstate, ntot, nshells, self.Nsmoke, self.Nillu, self.Nukes, self.nukewarhead/1000000, nrockets, nmissiles))
|
||||
|
||||
if self.Controllable and self.Controllable:IsAlive() then
|
||||
|
||||
@@ -4814,7 +4814,8 @@ function ARTY:_CheckShootingStarted()
|
||||
end
|
||||
|
||||
-- Check if we waited long enough and no shot was fired.
|
||||
if dt > self.WaitForShotTime and self.Nshots==0 then
|
||||
--if dt > self.WaitForShotTime and self.Nshots==0 then
|
||||
if dt > self.WaitForShotTime and (self.Nshots==0 or self.currentTarget.nshells >= self.Nshots) then --https://github.com/FlightControl-Master/MOOSE/issues/1356
|
||||
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("%s, no shot event after %d seconds. Removing current target %s from list.", self.groupname, self.WaitForShotTime, name))
|
||||
|
||||
@@ -7025,7 +7025,7 @@ function WAREHOUSE:_CheckRequestNow(request)
|
||||
|
||||
-- If no transport is requested, assets need to be mobile unless it is a self request.
|
||||
local onlymobile=false
|
||||
if type(request.transport)=="number" and request.ntransport==0 and not request.toself then
|
||||
if type(request.ntransport)=="number" and request.ntransport==0 and not request.toself then
|
||||
onlymobile=true
|
||||
end
|
||||
|
||||
|
||||
@@ -1273,17 +1273,19 @@ AIRBOSS.AircraftCarrier={
|
||||
|
||||
--- Carrier types.
|
||||
-- @type AIRBOSS.CarrierType
|
||||
-- @field #string ROOSEVELT USS Theodore Roosevelt (CVN-71)
|
||||
-- @field #string LINCOLN USS Abraham Lincoln (CVN-72)
|
||||
-- @field #string WASHINGTON USS George Washington (CVN-73)
|
||||
-- @field #string ROOSEVELT USS Theodore Roosevelt (CVN-71) [Super Carrier Module]
|
||||
-- @field #string LINCOLN USS Abraham Lincoln (CVN-72) [Super Carrier Module]
|
||||
-- @field #string WASHINGTON USS George Washington (CVN-73) [Super Carrier Module]
|
||||
-- @field #string STENNIS USS John C. Stennis (CVN-74)
|
||||
-- @field #string VINSON USS Carl Vinson (CVN-70)
|
||||
-- @field #string TRUMAN USS Harry S. Truman (CVN-75) [Super Carrier Module]
|
||||
-- @field #string VINSON USS Carl Vinson (CVN-70) [Obsolete]
|
||||
-- @field #string TARAWA USS Tarawa (LHA-1)
|
||||
-- @field #string KUZNETSOV Admiral Kuznetsov (CV 1143.5)
|
||||
AIRBOSS.CarrierType={
|
||||
ROOSEVELT="CVN_71",
|
||||
LINCOLN="CVN_72",
|
||||
WASHINGTON="CVN_73",
|
||||
TRUMAN="CVN_75",
|
||||
STENNIS="Stennis",
|
||||
VINSON="VINSON",
|
||||
TARAWA="LHA_Tarawa",
|
||||
@@ -1939,8 +1941,10 @@ function AIRBOSS:New(carriername, alias)
|
||||
self:_InitNimitz()
|
||||
elseif self.carriertype==AIRBOSS.CarrierType.LINCOLN then
|
||||
self:_InitNimitz()
|
||||
elseif self.carriertype==AIRBOSS.CarrierType.WASHINGTON then
|
||||
elseif self.carriertype==AIRBOSS.CarrierType.WASHINGTON then
|
||||
self:_InitNimitz()
|
||||
elseif self.carriertype==AIRBOSS.CarrierType.TRUMAN then
|
||||
self:_InitNimitz()
|
||||
elseif self.carriertype==AIRBOSS.CarrierType.VINSON then
|
||||
-- TODO: Carl Vinson parameters.
|
||||
self:_InitStennis()
|
||||
@@ -2464,7 +2468,7 @@ function AIRBOSS:AddRecoveryWindow(starttime, stoptime, case, holdingoffset, tur
|
||||
local Tstart=UTILS.ClockToSeconds(starttime)
|
||||
|
||||
-- Set stop time.
|
||||
local Tstop=UTILS.ClockToSeconds(stoptime or Tstart+90*60)
|
||||
local Tstop=stoptime and UTILS.ClockToSeconds(stoptime) or Tstart+90*60
|
||||
|
||||
-- Consistancy check for timing.
|
||||
if Tstart>Tstop then
|
||||
@@ -7895,7 +7899,7 @@ end
|
||||
function AIRBOSS:_RemoveUnitFromFlight(unit)
|
||||
|
||||
-- Check if unit exists.
|
||||
if unit then
|
||||
if unit and unit:IsInstanceOf("UNIT") then
|
||||
|
||||
-- Get group.
|
||||
local group=unit:GetGroup()
|
||||
@@ -14048,10 +14052,10 @@ function AIRBOSS:_GetOnboardNumbers(group, playeronly)
|
||||
-- Onboard number and unit name.
|
||||
local n=tostring(unit.onboard_num)
|
||||
local name=unit.name
|
||||
local skill=unit.skill
|
||||
local skill=unit.skill or "Unknown"
|
||||
|
||||
-- Debug text.
|
||||
text=text..string.format("\n- unit %s: onboard #=%s skill=%s", name, n, skill)
|
||||
text=text..string.format("\n- unit %s: onboard #=%s skill=%s", name, n, tostring(skill))
|
||||
|
||||
if playeronly and skill=="Client" or skill=="Player" then
|
||||
-- There can be only one player in the group, so we skip everything else.
|
||||
|
||||
@@ -1272,8 +1272,7 @@ function AIRBASE:GetRunwayData(magvar, mark)
|
||||
name==AIRBASE.PersianGulf.Abu_Dhabi_International_Airport or
|
||||
name==AIRBASE.PersianGulf.Dubai_Intl or
|
||||
name==AIRBASE.PersianGulf.Shiraz_International_Airport or
|
||||
name==AIRBASE.PersianGulf.Kish_International_Airport
|
||||
then
|
||||
name==AIRBASE.PersianGulf.Kish_International_Airport then
|
||||
|
||||
-- 1-->4, 2-->3, 3-->2, 4-->1
|
||||
exception=1
|
||||
@@ -1290,13 +1289,14 @@ function AIRBASE:GetRunwayData(magvar, mark)
|
||||
|
||||
end
|
||||
|
||||
--- Function returning the index of the runway coordinate belonding to the given index i.
|
||||
local function f(i)
|
||||
|
||||
local j
|
||||
|
||||
if exception==1 then
|
||||
|
||||
j=N-(i+1) -- 1-->4, 2-->3
|
||||
j=N-(i-1) -- 1-->4, 2-->3
|
||||
|
||||
elseif exception==2 then
|
||||
|
||||
@@ -1357,6 +1357,9 @@ function AIRBASE:GetRunwayData(magvar, mark)
|
||||
|
||||
-- Get the other spawn point coordinate.
|
||||
local j=f(i)
|
||||
|
||||
-- Debug info.
|
||||
--env.info(string.format("Runway i=%s j=%s (N=%d #runwaycoord=%d)", tostring(i), tostring(j), N, #runwaycoords))
|
||||
|
||||
-- Coordinates of the two runway points.
|
||||
local c1=runwaycoords[i] --Core.Point#COORDINATE
|
||||
|
||||
@@ -2828,7 +2828,7 @@ function CONTROLLABLE:GetDetectedUnitSet(DetectVisual, DetectOptical, DetectRada
|
||||
return unitset
|
||||
end
|
||||
|
||||
--- Return the detected target groups of the controllable as a @{SET_GROUP}.
|
||||
--- Return the detected target groups of the controllable as a @{Core.Set#SET_GROUP}.
|
||||
-- The optional parametes specify the detection methods that can be applied.
|
||||
-- If no detection method is given, the detection will use all the available methods by default.
|
||||
-- @param Wrapper.Controllable#CONTROLLABLE self
|
||||
|
||||
@@ -2202,27 +2202,52 @@ function GROUP:IsAirborne(AllUnits)
|
||||
|
||||
if units then
|
||||
|
||||
for _,_unit in pairs(units) do
|
||||
local unit=_unit --Wrapper.Unit#UNIT
|
||||
|
||||
if unit then
|
||||
|
||||
-- Unit in air or not.
|
||||
local inair=unit:InAir()
|
||||
if AllUnits then
|
||||
|
||||
--- We want to know if ALL units are airborne.
|
||||
|
||||
for _,_unit in pairs(units) do
|
||||
local unit=_unit --Wrapper.Unit#UNIT
|
||||
|
||||
-- Unit is not in air and we wanted to know whether ALL units are ==> return false
|
||||
if inair==false and AllUnits==true then
|
||||
return false
|
||||
end
|
||||
if unit then
|
||||
|
||||
-- At least one unit is in are and we did not care which one.
|
||||
if inair==true and not AllUnits then
|
||||
return true
|
||||
-- Unit in air or not.
|
||||
local inair=unit:InAir()
|
||||
|
||||
-- At least one unit is not in air.
|
||||
if not inair then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
-- At least one unit is in the air.
|
||||
return true
|
||||
|
||||
-- All units are in air.
|
||||
return true
|
||||
|
||||
else
|
||||
|
||||
--- We want to know if ANY unit is airborne.
|
||||
|
||||
for _,_unit in pairs(units) do
|
||||
local unit=_unit --Wrapper.Unit#UNIT
|
||||
|
||||
if unit then
|
||||
|
||||
-- Unit in air or not.
|
||||
local inair=unit:InAir()
|
||||
|
||||
if inair then
|
||||
-- At least one unit is in air.
|
||||
return true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- No unit is in air.
|
||||
return false
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1180,23 +1180,26 @@ do -- Event Handling
|
||||
|
||||
--- Subscribe to a DCS Event.
|
||||
-- @param #UNIT self
|
||||
-- @param Core.Event#EVENTS Event
|
||||
-- @param #function EventFunction (optional) The function to be called when the event occurs for the unit.
|
||||
-- @return #UNIT
|
||||
function UNIT:HandleEvent( Event, EventFunction )
|
||||
-- @param Core.Event#EVENTS EventID Event ID.
|
||||
-- @param #function EventFunction (Optional) The function to be called when the event occurs for the unit.
|
||||
-- @return #UNIT self
|
||||
function UNIT:HandleEvent(EventID, EventFunction)
|
||||
|
||||
self:EventDispatcher():OnEventForUnit( self:GetName(), EventFunction, self, Event )
|
||||
self:EventDispatcher():OnEventForUnit(self:GetName(), EventFunction, self, EventID)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- UnSubscribe to a DCS event.
|
||||
-- @param #UNIT self
|
||||
-- @param Core.Event#EVENTS Event
|
||||
-- @return #UNIT
|
||||
function UNIT:UnHandleEvent( Event )
|
||||
-- @param Core.Event#EVENTS EventID Event ID.
|
||||
-- @return #UNIT self
|
||||
function UNIT:UnHandleEvent(EventID)
|
||||
|
||||
self:EventDispatcher():RemoveForUnit( self:GetName(), self, Event )
|
||||
--self:EventDispatcher():RemoveForUnit( self:GetName(), self, EventID )
|
||||
|
||||
-- Fixes issue #1365 https://github.com/FlightControl-Master/MOOSE/issues/1365
|
||||
self:EventDispatcher():RemoveEvent(self, EventID)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user