mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Ops
This commit is contained in:
parent
d93d0afdf3
commit
f2e417b21f
@ -283,7 +283,7 @@
|
||||
--
|
||||
-- Assets of the warehouse can be requested by other MOOSE warehouses. A request will first be scrutinized to check if can be fulfilled at all. If the request is valid, it is
|
||||
-- put into the warehouse queue and processed as soon as possible.
|
||||
--
|
||||
--
|
||||
-- Requested assets spawn in various "Rule of Engagement Rules" (ROE) and Alerts modes. If your assets will cross into dangerous areas, be sure to change these states. You can do this in @{#WAREHOUSE:OnAfterAssetSpawned}(*From, *Event, *To, *group, *asset, *request)) function.
|
||||
--
|
||||
-- Initial Spawn states is as follows:
|
||||
@ -1870,10 +1870,10 @@ function WAREHOUSE:New(warehouse, alias)
|
||||
|
||||
-- Set unique ID for this warehouse.
|
||||
self.uid=_WAREHOUSEDB.WarehouseID
|
||||
|
||||
|
||||
-- Coalition of the warehouse.
|
||||
self.coalition=self.warehouse:GetCoalition()
|
||||
|
||||
|
||||
-- Country of the warehouse.
|
||||
self.countryid=self.warehouse:GetCountry()
|
||||
|
||||
@ -1886,7 +1886,7 @@ function WAREHOUSE:New(warehouse, alias)
|
||||
-- Define warehouse and default spawn zone.
|
||||
self.zone=ZONE_RADIUS:New(string.format("Warehouse zone %s", self.warehouse:GetName()), warehouse:GetVec2(), 500)
|
||||
self.spawnzone=ZONE_RADIUS:New(string.format("Warehouse %s spawn zone", self.warehouse:GetName()), warehouse:GetVec2(), 250)
|
||||
|
||||
|
||||
-- Defaults
|
||||
self:SetMarker(true)
|
||||
|
||||
@ -1904,26 +1904,26 @@ function WAREHOUSE:New(warehouse, alias)
|
||||
-- From State --> Event --> To State
|
||||
self:AddTransition("NotReadyYet", "Load", "Loaded") -- Load the warehouse state from scatch.
|
||||
self:AddTransition("Stopped", "Load", "Loaded") -- Load the warehouse state stopped state.
|
||||
|
||||
|
||||
self:AddTransition("NotReadyYet", "Start", "Running") -- Start the warehouse from scratch.
|
||||
self:AddTransition("Loaded", "Start", "Running") -- Start the warehouse when loaded from disk.
|
||||
|
||||
|
||||
self:AddTransition("*", "Status", "*") -- Status update.
|
||||
|
||||
|
||||
self:AddTransition("*", "AddAsset", "*") -- Add asset to warehouse stock.
|
||||
self:AddTransition("*", "NewAsset", "*") -- New asset was added to warehouse stock.
|
||||
|
||||
|
||||
self:AddTransition("*", "AddRequest", "*") -- New request from other warehouse.
|
||||
self:AddTransition("Running", "Request", "*") -- Process a request. Only in running mode.
|
||||
self:AddTransition("Running", "RequestSpawned", "*") -- Assets of request were spawned.
|
||||
self:AddTransition("Attacked", "Request", "*") -- Process a request. Only in running mode.
|
||||
|
||||
|
||||
self:AddTransition("*", "Unloaded", "*") -- Cargo has been unloaded from the carrier (unused ==> unnecessary?).
|
||||
self:AddTransition("*", "AssetSpawned", "*") -- Asset has been spawned into the world.
|
||||
self:AddTransition("*", "AssetLowFuel", "*") -- Asset is low on fuel.
|
||||
|
||||
|
||||
self:AddTransition("*", "Arrived", "*") -- Cargo or transport group has arrived.
|
||||
|
||||
|
||||
self:AddTransition("*", "Delivered", "*") -- All cargo groups of a request have been delivered to the requesting warehouse.
|
||||
self:AddTransition("Running", "SelfRequest", "*") -- Request to warehouse itself. Requested assets are only spawned but not delivered anywhere.
|
||||
self:AddTransition("Attacked", "SelfRequest", "*") -- Request to warehouse itself. Also possible when warehouse is under attack!
|
||||
@ -3402,7 +3402,7 @@ end
|
||||
function WAREHOUSE:onafterStatus(From, Event, To)
|
||||
|
||||
local FSMstate=self:GetState()
|
||||
|
||||
|
||||
local coalition=self:GetCoalitionName()
|
||||
local country=self:GetCountryName()
|
||||
|
||||
@ -3751,7 +3751,7 @@ function WAREHOUSE:onafterAddAsset(From, Event, To, group, ngroups, forceattribu
|
||||
local wid,aid,rid=self:_GetIDsFromGroup(group)
|
||||
|
||||
if wid and aid and rid then
|
||||
|
||||
|
||||
---------------------------
|
||||
-- This is a KNOWN asset --
|
||||
---------------------------
|
||||
@ -3767,7 +3767,7 @@ function WAREHOUSE:onafterAddAsset(From, Event, To, group, ngroups, forceattribu
|
||||
|
||||
-- Increase number of cargo delivered and transports home.
|
||||
local istransport=warehouse:_GroupIsTransport(group,request)
|
||||
|
||||
|
||||
if istransport==true then
|
||||
request.ntransporthome=request.ntransporthome+1
|
||||
request.transportgroupset:Remove(group:GetName(), true)
|
||||
@ -3777,7 +3777,7 @@ function WAREHOUSE:onafterAddAsset(From, Event, To, group, ngroups, forceattribu
|
||||
request.ndelivered=request.ndelivered+1
|
||||
local namewo=self:_GetNameWithOut(group)
|
||||
request.cargogroupset:Remove(namewo, true)
|
||||
local ncargo=request.cargogroupset:Count()
|
||||
local ncargo=request.cargogroupset:Count()
|
||||
self:T2(warehouse.lid..string.format("Cargo %s: %d of %s delivered. CargoSet=%d", namewo, request.ndelivered, tostring(request.nasset), ncargo))
|
||||
else
|
||||
self:E(warehouse.lid..string.format("WARNING: Group %s is neither cargo nor transport! Need to investigate...", group:GetName()))
|
||||
@ -3807,10 +3807,10 @@ function WAREHOUSE:onafterAddAsset(From, Event, To, group, ngroups, forceattribu
|
||||
asset.livery=liveries
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Set skill.
|
||||
asset.skill=skill or asset.skill
|
||||
|
||||
|
||||
-- Asset now belongs to this warehouse. Set warehouse ID.
|
||||
asset.wid=self.uid
|
||||
|
||||
@ -3832,7 +3832,7 @@ function WAREHOUSE:onafterAddAsset(From, Event, To, group, ngroups, forceattribu
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
|
||||
-------------------------
|
||||
-- This is a NEW asset --
|
||||
-------------------------
|
||||
@ -4113,7 +4113,7 @@ function WAREHOUSE:onbeforeAddRequest(From, Event, To, warehouse, AssetDescripto
|
||||
self:_ErrorMessage("ERROR: Invalid request. Asset assignment type must be passed as a string!", 5)
|
||||
okay=false
|
||||
end
|
||||
|
||||
|
||||
elseif AssetDescriptor==WAREHOUSE.Descriptor.ASSETLIST then
|
||||
|
||||
if type(AssetDescriptorValue)~="table" then
|
||||
@ -4315,7 +4315,7 @@ function WAREHOUSE:onafterRequest(From, Event, To, Request)
|
||||
_assetitem.arrived=false
|
||||
|
||||
local spawngroup=nil --Wrapper.Group#GROUP
|
||||
|
||||
|
||||
-- Add asset by id to all assets table.
|
||||
Request.assets[_assetitem.uid]=_assetitem
|
||||
|
||||
@ -4735,7 +4735,7 @@ end
|
||||
function WAREHOUSE:onbeforeArrived(From, Event, To, group)
|
||||
|
||||
local asset=self:FindAssetInDB(group)
|
||||
|
||||
|
||||
if asset then
|
||||
if asset.arrived==true then
|
||||
-- Asset already arrived (e.g. if multiple units trigger the event via landing).
|
||||
@ -4745,7 +4745,7 @@ function WAREHOUSE:onbeforeArrived(From, Event, To, group)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
--- On after "Arrived" event. Triggered when a group has arrived at its destination warehouse.
|
||||
@ -4789,7 +4789,7 @@ function WAREHOUSE:onafterArrived(From, Event, To, group)
|
||||
if group:IsGround() and group:GetSpeedMax()>1 then
|
||||
group:RouteGroundTo(warehouse:GetCoordinate(), group:GetSpeedMax()*0.3, "Off Road")
|
||||
end
|
||||
|
||||
|
||||
-- NOTE: This is done in the AddAsset() function. Dont know, why we do it also here.
|
||||
--[[
|
||||
if istransport==true then
|
||||
@ -4804,7 +4804,7 @@ function WAREHOUSE:onafterArrived(From, Event, To, group)
|
||||
self:E(warehouse.lid..string.format("ERROR: Group %s is neither cargo nor transport!", group:GetName()))
|
||||
end
|
||||
]]
|
||||
|
||||
|
||||
-- Move asset from pending queue into new warehouse.
|
||||
warehouse:__AddAsset(60, group)
|
||||
end
|
||||
@ -5011,15 +5011,15 @@ function WAREHOUSE:onafterChangeCountry(From, Event, To, Country)
|
||||
-- Delete all waiting requests because they are not valid any more.
|
||||
self.queue=nil
|
||||
self.queue={}
|
||||
|
||||
|
||||
if self.airbasename then
|
||||
|
||||
|
||||
-- Get airbase of this warehouse.
|
||||
local airbase=AIRBASE:FindByName(self.airbasename)
|
||||
|
||||
|
||||
-- Get coalition of the airbase.
|
||||
local airbaseCoalition=airbase:GetCoalition()
|
||||
|
||||
local airbaseCoalition=airbase:GetCoalition()
|
||||
|
||||
if CoalitionNew==airbaseCoalition then
|
||||
-- Airbase already owned by the coalition that captured the warehouse. Airbase can be used by this warehouse.
|
||||
self.airbase=airbase
|
||||
@ -5027,7 +5027,7 @@ function WAREHOUSE:onafterChangeCountry(From, Event, To, Country)
|
||||
-- Airbase is owned by other coalition. So this warehouse does not have an airbase until it is captured.
|
||||
self.airbase=nil
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
-- Debug smoke.
|
||||
@ -5067,7 +5067,7 @@ function WAREHOUSE:onafterCaptured(From, Event, To, Coalition, Country)
|
||||
-- Message.
|
||||
local text=string.format("Warehouse %s: We were captured by enemy coalition (side=%d)!", self.alias, Coalition)
|
||||
self:_InfoMessage(text)
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
@ -5122,7 +5122,7 @@ function WAREHOUSE:onafterAirbaseRecaptured(From, Event, To, Coalition)
|
||||
|
||||
end
|
||||
|
||||
--- On before "AssetSpawned" event. Checks whether the asset was already set to "spawned" for groups with multiple units.
|
||||
--- On before "AssetSpawned" event. Checks whether the asset was already set to "spawned" for groups with multiple units.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
@ -5136,7 +5136,7 @@ function WAREHOUSE:onbeforeAssetSpawned(From, Event, To, group, asset, request)
|
||||
else
|
||||
--return true
|
||||
end
|
||||
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
@ -5162,7 +5162,7 @@ function WAREHOUSE:onafterAssetSpawned(From, Event, To, group, asset, request)
|
||||
|
||||
-- Debug info.
|
||||
self:T2(self.lid..string.format("Asset %s spawned %s as %s", assetitem.templatename, tostring(assetitem.spawned), tostring(assetitem.spawngroupname)))
|
||||
|
||||
|
||||
if assetitem.spawned then
|
||||
n=n+1
|
||||
else
|
||||
@ -5221,11 +5221,11 @@ function WAREHOUSE:onafterDestroyed(From, Event, To)
|
||||
for k,_ in pairs(self.queue) do
|
||||
self.queue[k]=nil
|
||||
end
|
||||
|
||||
|
||||
for k,_ in pairs(self.stock) do
|
||||
--self.stock[k]=nil
|
||||
end
|
||||
|
||||
|
||||
for k=#self.stock,1,-1 do
|
||||
--local asset=self.stock[k] --#WAREHOUSE.Assetitem
|
||||
--self:AssetDead(asset, nil)
|
||||
@ -5488,15 +5488,15 @@ function WAREHOUSE:_SpawnAssetRequest(Request)
|
||||
-- Set asset status to not spawned until we capture its birth event.
|
||||
asset.spawned=false
|
||||
asset.iscargo=true
|
||||
|
||||
|
||||
-- Set request ID.
|
||||
asset.rid=Request.uid
|
||||
|
||||
-- Spawn group name.
|
||||
local _alias=asset.spawngroupname
|
||||
|
||||
|
||||
--Request add asset by id.
|
||||
Request.assets[asset.uid]=asset
|
||||
Request.assets[asset.uid]=asset
|
||||
|
||||
-- Spawn an asset group.
|
||||
local _group=nil --Wrapper.Group#GROUP
|
||||
@ -5588,7 +5588,7 @@ function WAREHOUSE:_SpawnAssetGroundNaval(alias, asset, request, spawnzone, aiof
|
||||
end
|
||||
if asset.skill then
|
||||
unit.skill= asset.skill
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -5724,15 +5724,15 @@ function WAREHOUSE:_SpawnAssetAircraft(alias, asset, request, parking, uncontrol
|
||||
end
|
||||
|
||||
if asset.payload then
|
||||
unit.payload=asset.payload.pylons
|
||||
unit.payload=asset.payload.pylons
|
||||
end
|
||||
|
||||
|
||||
if asset.modex then
|
||||
unit.onboard_num=asset.modex[i]
|
||||
end
|
||||
if asset.callsign then
|
||||
unit.callsign=asset.callsign[i]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -5785,12 +5785,12 @@ function WAREHOUSE:_SpawnAssetPrepareTemplate(asset, alias)
|
||||
|
||||
-- No late activation.
|
||||
template.lateActivation=false
|
||||
|
||||
|
||||
if asset.missionTask then
|
||||
self:I(self.lid..string.format("Setting mission task to %s", tostring(asset.missionTask)))
|
||||
template.task=asset.missionTask
|
||||
end
|
||||
|
||||
|
||||
-- No predefined task.
|
||||
--template.taskSelected=false
|
||||
|
||||
@ -6069,7 +6069,7 @@ end
|
||||
--- Get a warehouse request from its unique id.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param #number id Request ID.
|
||||
-- @return #WAREHOUSE.Pendingitem The warehouse requested - either queued or pending.
|
||||
-- @return #WAREHOUSE.Pendingitem The warehouse requested - either queued or pending.
|
||||
-- @return #boolean If *true*, request is queued, if *false*, request is pending, if *nil*, request could not be found.
|
||||
function WAREHOUSE:GetRequestByID(id)
|
||||
|
||||
@ -6107,14 +6107,14 @@ function WAREHOUSE:_OnEventBirth(EventData)
|
||||
local wid,aid,rid=self:_GetIDsFromGroup(group)
|
||||
|
||||
if wid==self.uid then
|
||||
|
||||
|
||||
-- Get asset and request from id.
|
||||
local asset=self:GetAssetByID(aid)
|
||||
local request=self:GetRequestByID(rid)
|
||||
|
||||
|
||||
-- Debug message.
|
||||
self:T(self.lid..string.format("Warehouse %s captured event birth of its asset unit %s. spawned=%s", self.alias, EventData.IniUnitName, tostring(asset.spawned)))
|
||||
|
||||
|
||||
-- Birth is triggered for each unit. We need to make sure not to call this too often!
|
||||
if not asset.spawned then
|
||||
|
||||
@ -6399,7 +6399,7 @@ function WAREHOUSE:_UnitDead(deadunit, request)
|
||||
-- Remove dead group from cargo group set.
|
||||
if groupdead==true then
|
||||
request.cargogroupset:Remove(groupname, NoTriggerEvent)
|
||||
self:T(self.lid..string.format("Removed selfpropelled cargo %s: ncargo=%d.", groupname, request.cargogroupset:Count()))
|
||||
self:T(self.lid..string.format("Removed selfpropelled cargo %s: ncargo=%d.", groupname, request.cargogroupset:Count()))
|
||||
end
|
||||
|
||||
else
|
||||
@ -7715,27 +7715,27 @@ end
|
||||
function WAREHOUSE:_GroupIsTransport(group, request)
|
||||
|
||||
local asset=self:FindAssetInDB(group)
|
||||
|
||||
|
||||
if asset and asset.iscargo~=nil then
|
||||
return not asset.iscargo
|
||||
else
|
||||
|
||||
-- Name of the group under question.
|
||||
local groupname=self:_GetNameWithOut(group)
|
||||
|
||||
|
||||
if request.transportgroupset then
|
||||
local transporters=request.transportgroupset:GetSetObjects()
|
||||
|
||||
|
||||
for _,transport in pairs(transporters) do
|
||||
if transport:GetName()==groupname then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if request.cargogroupset then
|
||||
local cargos=request.cargogroupset:GetSetObjects()
|
||||
|
||||
|
||||
for _,cargo in pairs(cargos) do
|
||||
if self:_GetNameWithOut(cargo)==groupname then
|
||||
return false
|
||||
@ -7755,14 +7755,14 @@ end
|
||||
function WAREHOUSE:_GetNameWithOut(group)
|
||||
|
||||
local groupname=type(group)=="string" and group or group:GetName()
|
||||
|
||||
|
||||
if groupname:find("CARGO") then
|
||||
local name=groupname:gsub("#CARGO", "")
|
||||
return name
|
||||
else
|
||||
return groupname
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
@ -7925,23 +7925,23 @@ function WAREHOUSE:_FilterStock(stock, descriptor, attribute, nmax, mobile)
|
||||
|
||||
-- Filtered array.
|
||||
local filtered={}
|
||||
|
||||
|
||||
-- A specific list of assets was required.
|
||||
if descriptor==WAREHOUSE.Descriptor.ASSETLIST then
|
||||
|
||||
-- Count total number in stock.
|
||||
local ntot=0
|
||||
for _,_rasset in pairs(attribute) do
|
||||
local rasset=_rasset --#WAREHOUSE.Assetitem
|
||||
local rasset=_rasset --#WAREHOUSE.Assetitem
|
||||
for _,_asset in ipairs(stock) do
|
||||
local asset=_asset --#WAREHOUSE.Assetitem
|
||||
local asset=_asset --#WAREHOUSE.Assetitem
|
||||
if rasset.uid==asset.uid then
|
||||
table.insert(filtered, asset)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return filtered, #filtered, #filtered>=#attribute
|
||||
end
|
||||
|
||||
@ -8410,25 +8410,25 @@ function WAREHOUSE:_UpdateWarehouseMarkText()
|
||||
if self.markerid~=nil then
|
||||
trigger.action.removeMark(self.markerid)
|
||||
end
|
||||
|
||||
|
||||
-- Get assets in stock.
|
||||
local _data=self:GetStockInfo(self.stock)
|
||||
|
||||
|
||||
-- Text.
|
||||
local text=string.format("Warehouse state: %s\nTotal assets in stock %d:\n", self:GetState(), #self.stock)
|
||||
|
||||
|
||||
for _attribute,_count in pairs(_data) do
|
||||
if _count>0 then
|
||||
local attribute=tostring(UTILS.Split(_attribute, "_")[2])
|
||||
text=text..string.format("%s=%d, ", attribute,_count)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Create/update marker at warehouse in F10 map.
|
||||
self.markerid=self:GetCoordinate():MarkToCoalition(text, self:GetCoalition(), true)
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
--- Display stock items of warehouse.
|
||||
|
||||
@ -2973,7 +2973,7 @@ function AUFTRAG:GetDCSMissionTask(TaskControllable)
|
||||
-- FAC Mission --
|
||||
-----------------
|
||||
|
||||
local DCStask=CONTROLLABLE.TaskFAC_AttackGroup(nil, self.engageTarget.Target, self.engageWeaponType, self.facDesignation, self.facDatalink, self.facFrequency, self.facModulation, CallsignName, CallsignNumber)
|
||||
local DCStask=CONTROLLABLE.TaskFAC_AttackGroup(nil, self.engageTarget.Target, self.engageWeaponType, self.facDesignation, self.facDatalink, self.facFreq, self.facModu, CallsignName, CallsignNumber)
|
||||
|
||||
table.insert(DCStasks, DCStask)
|
||||
|
||||
|
||||
@ -296,13 +296,13 @@ function FLIGHTGROUP:New(group)
|
||||
self:AddTransition("*", "ElementOutOfAmmo", "*") -- An element is completely out of ammo.
|
||||
|
||||
|
||||
self:AddTransition("*", "FlightParking", "Parking") -- The whole flight group is parking.
|
||||
self:AddTransition("*", "FlightTaxiing", "Taxiing") -- The whole flight group is taxiing.
|
||||
self:AddTransition("*", "FlightTakeoff", "Airborne") -- The whole flight group is airborne.
|
||||
self:AddTransition("*", "FlightAirborne", "Airborne") -- The whole flight group is airborne.
|
||||
self:AddTransition("*", "FlightLanding", "Landing") -- The whole flight group is landing.
|
||||
self:AddTransition("*", "FlightLanded", "Landed") -- The whole flight group has landed.
|
||||
self:AddTransition("*", "FlightArrived", "Arrived") -- The whole flight group has arrived.
|
||||
self:AddTransition("*", "Parking", "Parking") -- The whole flight group is parking.
|
||||
self:AddTransition("*", "Taxiing", "Taxiing") -- The whole flight group is taxiing.
|
||||
self:AddTransition("*", "Takeoff", "Airborne") -- The whole flight group is airborne.
|
||||
self:AddTransition("*", "Airborne", "Airborne") -- The whole flight group is airborne.
|
||||
self:AddTransition("*", "Landing", "Landing") -- The whole flight group is landing.
|
||||
self:AddTransition("*", "Landed", "Landed") -- The whole flight group has landed.
|
||||
self:AddTransition("*", "Arrived", "Arrived") -- The whole flight group has arrived.
|
||||
|
||||
|
||||
------------------------
|
||||
@ -1115,13 +1115,13 @@ function FLIGHTGROUP:OnEventEngineShutdown(EventData)
|
||||
self:ElementArrived(element, airbase, parking)
|
||||
self:T3(self.lid..string.format("EVENT: Element %s shut down engines ==> arrived", element.name))
|
||||
else
|
||||
self:T3(self.lid..string.format("EVENT: Element %s shut down engines (in air) ==> dead", element.name))
|
||||
self:ElementDead(element)
|
||||
self:T3(self.lid..string.format("EVENT: Element %s shut down engines but is not parking. Is it dead?", element.name))
|
||||
--self:ElementDead(element)
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
self:I(self.lid..string.format("EVENT: Element %s shut down engines but is NOT alive ==> waiting for crash event (==> dead)", element.name))
|
||||
--self:I(self.lid..string.format("EVENT: Element %s shut down engines but is NOT alive ==> waiting for crash event (==> dead)", element.name))
|
||||
|
||||
end
|
||||
|
||||
@ -1165,6 +1165,19 @@ function FLIGHTGROUP:OnEventUnitLost(EventData)
|
||||
-- Check that this is the right group.
|
||||
if EventData and EventData.IniGroup and EventData.IniUnit and EventData.IniGroupName and EventData.IniGroupName==self.groupname then
|
||||
self:I(self.lid..string.format("EVENT: Unit %s lost!", EventData.IniUnitName))
|
||||
|
||||
local unit=EventData.IniUnit
|
||||
local group=EventData.IniGroup
|
||||
local unitname=EventData.IniUnitName
|
||||
|
||||
-- Get element.
|
||||
local element=self:GetElementByName(unitname)
|
||||
|
||||
if element then
|
||||
self:T3(self.lid..string.format("EVENT: Element %s crashed ==> dead", element.name))
|
||||
self:ElementDead(element)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -1434,12 +1447,12 @@ function FLIGHTGROUP:onafterSpawned(From, Event, To)
|
||||
|
||||
end
|
||||
|
||||
--- On after "FlightParking" event. Add flight to flightcontrol of airbase.
|
||||
--- On after "Parking" event. Add flight to flightcontrol of airbase.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
function FLIGHTGROUP:onafterFlightParking(From, Event, To)
|
||||
function FLIGHTGROUP:onafterParking(From, Event, To)
|
||||
self:I(self.lid..string.format("Flight is parking"))
|
||||
|
||||
local airbase=self.group:GetCoordinate():GetClosestAirbase()
|
||||
@ -1471,12 +1484,12 @@ function FLIGHTGROUP:onafterFlightParking(From, Event, To)
|
||||
end
|
||||
end
|
||||
|
||||
--- On after "FlightTaxiing" event.
|
||||
--- On after "Taxiing" event.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
function FLIGHTGROUP:onafterFlightTaxiing(From, Event, To)
|
||||
function FLIGHTGROUP:onafterTaxiing(From, Event, To)
|
||||
self:T(self.lid..string.format("Flight is taxiing"))
|
||||
|
||||
-- Parking over.
|
||||
@ -1502,13 +1515,13 @@ function FLIGHTGROUP:onafterFlightTaxiing(From, Event, To)
|
||||
|
||||
end
|
||||
|
||||
--- On after "FlightTakeoff" event.
|
||||
--- On after "Takeoff" event.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @param Wrapper.Airbase#AIRBASE airbase The airbase the flight landed.
|
||||
function FLIGHTGROUP:onafterFlightTakeoff(From, Event, To, airbase)
|
||||
function FLIGHTGROUP:onafterTakeoff(From, Event, To, airbase)
|
||||
self:T(self.lid..string.format("Flight takeoff from %s", airbase and airbase:GetName() or "unknown airbase"))
|
||||
|
||||
-- Remove flight from all FC queues.
|
||||
@ -1519,12 +1532,12 @@ function FLIGHTGROUP:onafterFlightTakeoff(From, Event, To, airbase)
|
||||
|
||||
end
|
||||
|
||||
--- On after "FlightAirborne" event.
|
||||
--- On after "Airborne" event.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
function FLIGHTGROUP:onafterFlightAirborne(From, Event, To)
|
||||
function FLIGHTGROUP:onafterAirborne(From, Event, To)
|
||||
self:I(self.lid..string.format("Flight airborne"))
|
||||
|
||||
if not self.ai then
|
||||
@ -1532,25 +1545,25 @@ function FLIGHTGROUP:onafterFlightAirborne(From, Event, To)
|
||||
end
|
||||
end
|
||||
|
||||
--- On after "FlightLanding" event.
|
||||
--- On after "Landing" event.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
function FLIGHTGROUP:onafterFlightLanding(From, Event, To)
|
||||
function FLIGHTGROUP:onafterLanding(From, Event, To)
|
||||
self:T(self.lid..string.format("Flight is landing"))
|
||||
|
||||
self:_SetElementStatusAll(OPSGROUP.ElementStatus.LANDING)
|
||||
|
||||
end
|
||||
|
||||
--- On after "FlightLanded" event.
|
||||
--- On after "Landed" event.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @param Wrapper.Airbase#AIRBASE airbase The airbase the flight landed.
|
||||
function FLIGHTGROUP:onafterFlightLanded(From, Event, To, airbase)
|
||||
function FLIGHTGROUP:onafterLanded(From, Event, To, airbase)
|
||||
self:T(self.lid..string.format("Flight landed at %s", airbase and airbase:GetName() or "unknown place"))
|
||||
|
||||
if self:IsLandingAt() then
|
||||
@ -1563,12 +1576,12 @@ function FLIGHTGROUP:onafterFlightLanded(From, Event, To, airbase)
|
||||
end
|
||||
end
|
||||
|
||||
--- On after "FlightArrived" event.
|
||||
--- On after "Arrived" event.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
function FLIGHTGROUP:onafterFlightArrived(From, Event, To)
|
||||
function FLIGHTGROUP:onafterArrived(From, Event, To)
|
||||
self:T(self.lid..string.format("Flight arrived"))
|
||||
|
||||
-- Flight Control
|
||||
@ -2445,8 +2458,8 @@ end
|
||||
function FLIGHTGROUP._ClearedToLand(group, flightgroup)
|
||||
flightgroup:I(flightgroup.lid..string.format("Group was cleared to land"))
|
||||
|
||||
-- Trigger FlightLanding event.
|
||||
flightgroup:__FlightLanding(-1)
|
||||
-- Trigger Landing event.
|
||||
flightgroup:__Landing(-1)
|
||||
end
|
||||
|
||||
--- Function called when flight finished refuelling.
|
||||
|
||||
@ -2452,7 +2452,7 @@ function OPSGROUP:_UpdateStatus(element, newstatus, airbase)
|
||||
---
|
||||
|
||||
if self:_AllSimilarStatus(newstatus) then
|
||||
self:__FlightParking(-0.5)
|
||||
self:__Parking(-0.5)
|
||||
end
|
||||
|
||||
elseif newstatus==OPSGROUP.ElementStatus.ENGINEON then
|
||||
@ -2468,7 +2468,7 @@ function OPSGROUP:_UpdateStatus(element, newstatus, airbase)
|
||||
---
|
||||
|
||||
if self:_AllSimilarStatus(newstatus) then
|
||||
self:__FlightTaxiing(-0.5)
|
||||
self:__Taxiing(-0.5)
|
||||
end
|
||||
|
||||
elseif newstatus==OPSGROUP.ElementStatus.TAKEOFF then
|
||||
@ -2478,7 +2478,7 @@ function OPSGROUP:_UpdateStatus(element, newstatus, airbase)
|
||||
|
||||
if self:_AllSimilarStatus(newstatus) then
|
||||
-- Trigger takeoff event. Also triggers airborne event.
|
||||
self:__FlightTakeoff(-0.5, airbase)
|
||||
self:__Takeoff(-0.5, airbase)
|
||||
end
|
||||
|
||||
elseif newstatus==OPSGROUP.ElementStatus.AIRBORNE then
|
||||
@ -2487,7 +2487,7 @@ function OPSGROUP:_UpdateStatus(element, newstatus, airbase)
|
||||
---
|
||||
|
||||
if self:_AllSimilarStatus(newstatus) then
|
||||
self:__FlightAirborne(-0.5)
|
||||
self:__Airborne(-0.5)
|
||||
end
|
||||
|
||||
elseif newstatus==OPSGROUP.ElementStatus.LANDED then
|
||||
@ -2496,7 +2496,7 @@ function OPSGROUP:_UpdateStatus(element, newstatus, airbase)
|
||||
---
|
||||
|
||||
if self:_AllSimilarStatus(newstatus) then
|
||||
self:FlightLanded(airbase)
|
||||
self:Landed(airbase)
|
||||
end
|
||||
|
||||
elseif newstatus==OPSGROUP.ElementStatus.ARRIVED then
|
||||
@ -2507,10 +2507,10 @@ function OPSGROUP:_UpdateStatus(element, newstatus, airbase)
|
||||
if self:_AllSimilarStatus(newstatus) then
|
||||
|
||||
if self:IsLanded() then
|
||||
self:FlightArrived()
|
||||
self:Arrived()
|
||||
elseif self:IsAirborne() then
|
||||
self:FlightLanded()
|
||||
self:FlightArrived()
|
||||
self:Landed()
|
||||
self:Arrived()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -1481,8 +1481,8 @@ end
|
||||
-- @param #number WeaponType Bitmask of weapon types, which are allowed to use.
|
||||
-- @param DCS#AI.Task.Designation Designation (Optional) Designation type.
|
||||
-- @param #boolean Datalink (Optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default.
|
||||
-- @param #number Frequency Frequency used to communicate with the FAC.
|
||||
-- @param #number Modulation Modulation of radio for communication.
|
||||
-- @param #number Frequency Frequency in MHz used to communicate with the FAC. Default 133 MHz.
|
||||
-- @param #number Modulation Modulation of radio for communication. Default 0=AM.
|
||||
-- @param #number CallsignName Callsign enumerator name of the FAC.
|
||||
-- @param #number CallsignNumber Callsign number, e.g. Axeman-**1**.
|
||||
-- @return DCS#Task The DCS task structure.
|
||||
@ -1492,11 +1492,11 @@ function CONTROLLABLE:TaskFAC_AttackGroup( AttackGroup, WeaponType, Designation,
|
||||
id = 'FAC_AttackGroup',
|
||||
params = {
|
||||
groupId = AttackGroup:GetID(),
|
||||
weaponType = WeaponType,
|
||||
designation = Designation,
|
||||
datalink = Datalink,
|
||||
frequency = Frequency,
|
||||
modulation = Modulation,
|
||||
weaponType = WeaponType or ENUMS.WeaponFlag.AutoDCS,
|
||||
designation = Designation or "Auto",
|
||||
datalink = Datalink and Datalink or true,
|
||||
frequency = (Frequency or 133)*1000000,
|
||||
modulation = Modulation or radio.modulation.AM,
|
||||
callname = CallsignName,
|
||||
number = CallsignNumber,
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user