This commit is contained in:
Frank 2020-07-01 23:52:27 +02:00
parent d93d0afdf3
commit f2e417b21f
5 changed files with 123 additions and 110 deletions

View File

@ -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 -- 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. -- 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. -- 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: -- Initial Spawn states is as follows:
@ -1870,10 +1870,10 @@ function WAREHOUSE:New(warehouse, alias)
-- Set unique ID for this warehouse. -- Set unique ID for this warehouse.
self.uid=_WAREHOUSEDB.WarehouseID self.uid=_WAREHOUSEDB.WarehouseID
-- Coalition of the warehouse. -- Coalition of the warehouse.
self.coalition=self.warehouse:GetCoalition() self.coalition=self.warehouse:GetCoalition()
-- Country of the warehouse. -- Country of the warehouse.
self.countryid=self.warehouse:GetCountry() self.countryid=self.warehouse:GetCountry()
@ -1886,7 +1886,7 @@ function WAREHOUSE:New(warehouse, alias)
-- Define warehouse and default spawn zone. -- Define warehouse and default spawn zone.
self.zone=ZONE_RADIUS:New(string.format("Warehouse zone %s", self.warehouse:GetName()), warehouse:GetVec2(), 500) 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) self.spawnzone=ZONE_RADIUS:New(string.format("Warehouse %s spawn zone", self.warehouse:GetName()), warehouse:GetVec2(), 250)
-- Defaults -- Defaults
self:SetMarker(true) self:SetMarker(true)
@ -1904,26 +1904,26 @@ function WAREHOUSE:New(warehouse, alias)
-- From State --> Event --> To State -- From State --> Event --> To State
self:AddTransition("NotReadyYet", "Load", "Loaded") -- Load the warehouse state from scatch. self:AddTransition("NotReadyYet", "Load", "Loaded") -- Load the warehouse state from scatch.
self:AddTransition("Stopped", "Load", "Loaded") -- Load the warehouse state stopped state. self:AddTransition("Stopped", "Load", "Loaded") -- Load the warehouse state stopped state.
self:AddTransition("NotReadyYet", "Start", "Running") -- Start the warehouse from scratch. self:AddTransition("NotReadyYet", "Start", "Running") -- Start the warehouse from scratch.
self:AddTransition("Loaded", "Start", "Running") -- Start the warehouse when loaded from disk. self:AddTransition("Loaded", "Start", "Running") -- Start the warehouse when loaded from disk.
self:AddTransition("*", "Status", "*") -- Status update. self:AddTransition("*", "Status", "*") -- Status update.
self:AddTransition("*", "AddAsset", "*") -- Add asset to warehouse stock. self:AddTransition("*", "AddAsset", "*") -- Add asset to warehouse stock.
self:AddTransition("*", "NewAsset", "*") -- New asset was added to warehouse stock. self:AddTransition("*", "NewAsset", "*") -- New asset was added to warehouse stock.
self:AddTransition("*", "AddRequest", "*") -- New request from other warehouse. self:AddTransition("*", "AddRequest", "*") -- New request from other warehouse.
self:AddTransition("Running", "Request", "*") -- Process a request. Only in running mode. self:AddTransition("Running", "Request", "*") -- Process a request. Only in running mode.
self:AddTransition("Running", "RequestSpawned", "*") -- Assets of request were spawned. self:AddTransition("Running", "RequestSpawned", "*") -- Assets of request were spawned.
self:AddTransition("Attacked", "Request", "*") -- Process a request. Only in running mode. 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("*", "Unloaded", "*") -- Cargo has been unloaded from the carrier (unused ==> unnecessary?).
self:AddTransition("*", "AssetSpawned", "*") -- Asset has been spawned into the world. self:AddTransition("*", "AssetSpawned", "*") -- Asset has been spawned into the world.
self:AddTransition("*", "AssetLowFuel", "*") -- Asset is low on fuel. self:AddTransition("*", "AssetLowFuel", "*") -- Asset is low on fuel.
self:AddTransition("*", "Arrived", "*") -- Cargo or transport group has arrived. 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("*", "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("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! 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) function WAREHOUSE:onafterStatus(From, Event, To)
local FSMstate=self:GetState() local FSMstate=self:GetState()
local coalition=self:GetCoalitionName() local coalition=self:GetCoalitionName()
local country=self:GetCountryName() local country=self:GetCountryName()
@ -3751,7 +3751,7 @@ function WAREHOUSE:onafterAddAsset(From, Event, To, group, ngroups, forceattribu
local wid,aid,rid=self:_GetIDsFromGroup(group) local wid,aid,rid=self:_GetIDsFromGroup(group)
if wid and aid and rid then if wid and aid and rid then
--------------------------- ---------------------------
-- This is a KNOWN asset -- -- 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. -- Increase number of cargo delivered and transports home.
local istransport=warehouse:_GroupIsTransport(group,request) local istransport=warehouse:_GroupIsTransport(group,request)
if istransport==true then if istransport==true then
request.ntransporthome=request.ntransporthome+1 request.ntransporthome=request.ntransporthome+1
request.transportgroupset:Remove(group:GetName(), true) request.transportgroupset:Remove(group:GetName(), true)
@ -3777,7 +3777,7 @@ function WAREHOUSE:onafterAddAsset(From, Event, To, group, ngroups, forceattribu
request.ndelivered=request.ndelivered+1 request.ndelivered=request.ndelivered+1
local namewo=self:_GetNameWithOut(group) local namewo=self:_GetNameWithOut(group)
request.cargogroupset:Remove(namewo, true) 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)) self:T2(warehouse.lid..string.format("Cargo %s: %d of %s delivered. CargoSet=%d", namewo, request.ndelivered, tostring(request.nasset), ncargo))
else else
self:E(warehouse.lid..string.format("WARNING: Group %s is neither cargo nor transport! Need to investigate...", group:GetName())) 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 asset.livery=liveries
end end
end end
-- Set skill. -- Set skill.
asset.skill=skill or asset.skill asset.skill=skill or asset.skill
-- Asset now belongs to this warehouse. Set warehouse ID. -- Asset now belongs to this warehouse. Set warehouse ID.
asset.wid=self.uid asset.wid=self.uid
@ -3832,7 +3832,7 @@ function WAREHOUSE:onafterAddAsset(From, Event, To, group, ngroups, forceattribu
end end
else else
------------------------- -------------------------
-- This is a NEW asset -- -- 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) self:_ErrorMessage("ERROR: Invalid request. Asset assignment type must be passed as a string!", 5)
okay=false okay=false
end end
elseif AssetDescriptor==WAREHOUSE.Descriptor.ASSETLIST then elseif AssetDescriptor==WAREHOUSE.Descriptor.ASSETLIST then
if type(AssetDescriptorValue)~="table" then if type(AssetDescriptorValue)~="table" then
@ -4315,7 +4315,7 @@ function WAREHOUSE:onafterRequest(From, Event, To, Request)
_assetitem.arrived=false _assetitem.arrived=false
local spawngroup=nil --Wrapper.Group#GROUP local spawngroup=nil --Wrapper.Group#GROUP
-- Add asset by id to all assets table. -- Add asset by id to all assets table.
Request.assets[_assetitem.uid]=_assetitem Request.assets[_assetitem.uid]=_assetitem
@ -4735,7 +4735,7 @@ end
function WAREHOUSE:onbeforeArrived(From, Event, To, group) function WAREHOUSE:onbeforeArrived(From, Event, To, group)
local asset=self:FindAssetInDB(group) local asset=self:FindAssetInDB(group)
if asset then if asset then
if asset.arrived==true then if asset.arrived==true then
-- Asset already arrived (e.g. if multiple units trigger the event via landing). -- 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 return true
end end
end end
end end
--- On after "Arrived" event. Triggered when a group has arrived at its destination warehouse. --- 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 if group:IsGround() and group:GetSpeedMax()>1 then
group:RouteGroundTo(warehouse:GetCoordinate(), group:GetSpeedMax()*0.3, "Off Road") group:RouteGroundTo(warehouse:GetCoordinate(), group:GetSpeedMax()*0.3, "Off Road")
end end
-- NOTE: This is done in the AddAsset() function. Dont know, why we do it also here. -- NOTE: This is done in the AddAsset() function. Dont know, why we do it also here.
--[[ --[[
if istransport==true then 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())) self:E(warehouse.lid..string.format("ERROR: Group %s is neither cargo nor transport!", group:GetName()))
end end
]] ]]
-- Move asset from pending queue into new warehouse. -- Move asset from pending queue into new warehouse.
warehouse:__AddAsset(60, group) warehouse:__AddAsset(60, group)
end end
@ -5011,15 +5011,15 @@ function WAREHOUSE:onafterChangeCountry(From, Event, To, Country)
-- Delete all waiting requests because they are not valid any more. -- Delete all waiting requests because they are not valid any more.
self.queue=nil self.queue=nil
self.queue={} self.queue={}
if self.airbasename then if self.airbasename then
-- Get airbase of this warehouse. -- Get airbase of this warehouse.
local airbase=AIRBASE:FindByName(self.airbasename) local airbase=AIRBASE:FindByName(self.airbasename)
-- Get coalition of the airbase. -- Get coalition of the airbase.
local airbaseCoalition=airbase:GetCoalition() local airbaseCoalition=airbase:GetCoalition()
if CoalitionNew==airbaseCoalition then if CoalitionNew==airbaseCoalition then
-- Airbase already owned by the coalition that captured the warehouse. Airbase can be used by this warehouse. -- Airbase already owned by the coalition that captured the warehouse. Airbase can be used by this warehouse.
self.airbase=airbase 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. -- Airbase is owned by other coalition. So this warehouse does not have an airbase until it is captured.
self.airbase=nil self.airbase=nil
end end
end end
-- Debug smoke. -- Debug smoke.
@ -5067,7 +5067,7 @@ function WAREHOUSE:onafterCaptured(From, Event, To, Coalition, Country)
-- Message. -- Message.
local text=string.format("Warehouse %s: We were captured by enemy coalition (side=%d)!", self.alias, Coalition) local text=string.format("Warehouse %s: We were captured by enemy coalition (side=%d)!", self.alias, Coalition)
self:_InfoMessage(text) self:_InfoMessage(text)
end end
@ -5122,7 +5122,7 @@ function WAREHOUSE:onafterAirbaseRecaptured(From, Event, To, Coalition)
end 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 #WAREHOUSE self
-- @param #string From From state. -- @param #string From From state.
-- @param #string Event Event. -- @param #string Event Event.
@ -5136,7 +5136,7 @@ function WAREHOUSE:onbeforeAssetSpawned(From, Event, To, group, asset, request)
else else
--return true --return true
end end
return true return true
end end
@ -5162,7 +5162,7 @@ function WAREHOUSE:onafterAssetSpawned(From, Event, To, group, asset, request)
-- Debug info. -- Debug info.
self:T2(self.lid..string.format("Asset %s spawned %s as %s", assetitem.templatename, tostring(assetitem.spawned), tostring(assetitem.spawngroupname))) self:T2(self.lid..string.format("Asset %s spawned %s as %s", assetitem.templatename, tostring(assetitem.spawned), tostring(assetitem.spawngroupname)))
if assetitem.spawned then if assetitem.spawned then
n=n+1 n=n+1
else else
@ -5221,11 +5221,11 @@ function WAREHOUSE:onafterDestroyed(From, Event, To)
for k,_ in pairs(self.queue) do for k,_ in pairs(self.queue) do
self.queue[k]=nil self.queue[k]=nil
end end
for k,_ in pairs(self.stock) do for k,_ in pairs(self.stock) do
--self.stock[k]=nil --self.stock[k]=nil
end end
for k=#self.stock,1,-1 do for k=#self.stock,1,-1 do
--local asset=self.stock[k] --#WAREHOUSE.Assetitem --local asset=self.stock[k] --#WAREHOUSE.Assetitem
--self:AssetDead(asset, nil) --self:AssetDead(asset, nil)
@ -5488,15 +5488,15 @@ function WAREHOUSE:_SpawnAssetRequest(Request)
-- Set asset status to not spawned until we capture its birth event. -- Set asset status to not spawned until we capture its birth event.
asset.spawned=false asset.spawned=false
asset.iscargo=true asset.iscargo=true
-- Set request ID. -- Set request ID.
asset.rid=Request.uid asset.rid=Request.uid
-- Spawn group name. -- Spawn group name.
local _alias=asset.spawngroupname local _alias=asset.spawngroupname
--Request add asset by id. --Request add asset by id.
Request.assets[asset.uid]=asset Request.assets[asset.uid]=asset
-- Spawn an asset group. -- Spawn an asset group.
local _group=nil --Wrapper.Group#GROUP local _group=nil --Wrapper.Group#GROUP
@ -5588,7 +5588,7 @@ function WAREHOUSE:_SpawnAssetGroundNaval(alias, asset, request, spawnzone, aiof
end end
if asset.skill then if asset.skill then
unit.skill= asset.skill unit.skill= asset.skill
end end
end end
@ -5724,15 +5724,15 @@ function WAREHOUSE:_SpawnAssetAircraft(alias, asset, request, parking, uncontrol
end end
if asset.payload then if asset.payload then
unit.payload=asset.payload.pylons unit.payload=asset.payload.pylons
end end
if asset.modex then if asset.modex then
unit.onboard_num=asset.modex[i] unit.onboard_num=asset.modex[i]
end end
if asset.callsign then if asset.callsign then
unit.callsign=asset.callsign[i] unit.callsign=asset.callsign[i]
end end
end end
@ -5785,12 +5785,12 @@ function WAREHOUSE:_SpawnAssetPrepareTemplate(asset, alias)
-- No late activation. -- No late activation.
template.lateActivation=false template.lateActivation=false
if asset.missionTask then if asset.missionTask then
self:I(self.lid..string.format("Setting mission task to %s", tostring(asset.missionTask))) self:I(self.lid..string.format("Setting mission task to %s", tostring(asset.missionTask)))
template.task=asset.missionTask template.task=asset.missionTask
end end
-- No predefined task. -- No predefined task.
--template.taskSelected=false --template.taskSelected=false
@ -6069,7 +6069,7 @@ end
--- Get a warehouse request from its unique id. --- Get a warehouse request from its unique id.
-- @param #WAREHOUSE self -- @param #WAREHOUSE self
-- @param #number id Request ID. -- @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. -- @return #boolean If *true*, request is queued, if *false*, request is pending, if *nil*, request could not be found.
function WAREHOUSE:GetRequestByID(id) function WAREHOUSE:GetRequestByID(id)
@ -6107,14 +6107,14 @@ function WAREHOUSE:_OnEventBirth(EventData)
local wid,aid,rid=self:_GetIDsFromGroup(group) local wid,aid,rid=self:_GetIDsFromGroup(group)
if wid==self.uid then if wid==self.uid then
-- Get asset and request from id. -- Get asset and request from id.
local asset=self:GetAssetByID(aid) local asset=self:GetAssetByID(aid)
local request=self:GetRequestByID(rid) local request=self:GetRequestByID(rid)
-- Debug message. -- 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))) 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! -- Birth is triggered for each unit. We need to make sure not to call this too often!
if not asset.spawned then if not asset.spawned then
@ -6399,7 +6399,7 @@ function WAREHOUSE:_UnitDead(deadunit, request)
-- Remove dead group from cargo group set. -- Remove dead group from cargo group set.
if groupdead==true then if groupdead==true then
request.cargogroupset:Remove(groupname, NoTriggerEvent) 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 end
else else
@ -7715,27 +7715,27 @@ end
function WAREHOUSE:_GroupIsTransport(group, request) function WAREHOUSE:_GroupIsTransport(group, request)
local asset=self:FindAssetInDB(group) local asset=self:FindAssetInDB(group)
if asset and asset.iscargo~=nil then if asset and asset.iscargo~=nil then
return not asset.iscargo return not asset.iscargo
else else
-- Name of the group under question. -- Name of the group under question.
local groupname=self:_GetNameWithOut(group) local groupname=self:_GetNameWithOut(group)
if request.transportgroupset then if request.transportgroupset then
local transporters=request.transportgroupset:GetSetObjects() local transporters=request.transportgroupset:GetSetObjects()
for _,transport in pairs(transporters) do for _,transport in pairs(transporters) do
if transport:GetName()==groupname then if transport:GetName()==groupname then
return true return true
end end
end end
end end
if request.cargogroupset then if request.cargogroupset then
local cargos=request.cargogroupset:GetSetObjects() local cargos=request.cargogroupset:GetSetObjects()
for _,cargo in pairs(cargos) do for _,cargo in pairs(cargos) do
if self:_GetNameWithOut(cargo)==groupname then if self:_GetNameWithOut(cargo)==groupname then
return false return false
@ -7755,14 +7755,14 @@ end
function WAREHOUSE:_GetNameWithOut(group) function WAREHOUSE:_GetNameWithOut(group)
local groupname=type(group)=="string" and group or group:GetName() local groupname=type(group)=="string" and group or group:GetName()
if groupname:find("CARGO") then if groupname:find("CARGO") then
local name=groupname:gsub("#CARGO", "") local name=groupname:gsub("#CARGO", "")
return name return name
else else
return groupname return groupname
end end
end end
@ -7925,23 +7925,23 @@ function WAREHOUSE:_FilterStock(stock, descriptor, attribute, nmax, mobile)
-- Filtered array. -- Filtered array.
local filtered={} local filtered={}
-- A specific list of assets was required. -- A specific list of assets was required.
if descriptor==WAREHOUSE.Descriptor.ASSETLIST then if descriptor==WAREHOUSE.Descriptor.ASSETLIST then
-- Count total number in stock. -- Count total number in stock.
local ntot=0 local ntot=0
for _,_rasset in pairs(attribute) do for _,_rasset in pairs(attribute) do
local rasset=_rasset --#WAREHOUSE.Assetitem local rasset=_rasset --#WAREHOUSE.Assetitem
for _,_asset in ipairs(stock) do for _,_asset in ipairs(stock) do
local asset=_asset --#WAREHOUSE.Assetitem local asset=_asset --#WAREHOUSE.Assetitem
if rasset.uid==asset.uid then if rasset.uid==asset.uid then
table.insert(filtered, asset) table.insert(filtered, asset)
break break
end end
end end
end end
return filtered, #filtered, #filtered>=#attribute return filtered, #filtered, #filtered>=#attribute
end end
@ -8410,25 +8410,25 @@ function WAREHOUSE:_UpdateWarehouseMarkText()
if self.markerid~=nil then if self.markerid~=nil then
trigger.action.removeMark(self.markerid) trigger.action.removeMark(self.markerid)
end end
-- Get assets in stock. -- Get assets in stock.
local _data=self:GetStockInfo(self.stock) local _data=self:GetStockInfo(self.stock)
-- Text. -- Text.
local text=string.format("Warehouse state: %s\nTotal assets in stock %d:\n", self:GetState(), #self.stock) local text=string.format("Warehouse state: %s\nTotal assets in stock %d:\n", self:GetState(), #self.stock)
for _attribute,_count in pairs(_data) do for _attribute,_count in pairs(_data) do
if _count>0 then if _count>0 then
local attribute=tostring(UTILS.Split(_attribute, "_")[2]) local attribute=tostring(UTILS.Split(_attribute, "_")[2])
text=text..string.format("%s=%d, ", attribute,_count) text=text..string.format("%s=%d, ", attribute,_count)
end end
end end
-- Create/update marker at warehouse in F10 map. -- Create/update marker at warehouse in F10 map.
self.markerid=self:GetCoordinate():MarkToCoalition(text, self:GetCoalition(), true) self.markerid=self:GetCoordinate():MarkToCoalition(text, self:GetCoalition(), true)
end end
end end
--- Display stock items of warehouse. --- Display stock items of warehouse.

View File

@ -2973,7 +2973,7 @@ function AUFTRAG:GetDCSMissionTask(TaskControllable)
-- FAC Mission -- -- 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) table.insert(DCStasks, DCStask)

View File

@ -296,13 +296,13 @@ function FLIGHTGROUP:New(group)
self:AddTransition("*", "ElementOutOfAmmo", "*") -- An element is completely out of ammo. self:AddTransition("*", "ElementOutOfAmmo", "*") -- An element is completely out of ammo.
self:AddTransition("*", "FlightParking", "Parking") -- The whole flight group is parking. self:AddTransition("*", "Parking", "Parking") -- The whole flight group is parking.
self:AddTransition("*", "FlightTaxiing", "Taxiing") -- The whole flight group is taxiing. self:AddTransition("*", "Taxiing", "Taxiing") -- The whole flight group is taxiing.
self:AddTransition("*", "FlightTakeoff", "Airborne") -- The whole flight group is airborne. self:AddTransition("*", "Takeoff", "Airborne") -- The whole flight group is airborne.
self:AddTransition("*", "FlightAirborne", "Airborne") -- The whole flight group is airborne. self:AddTransition("*", "Airborne", "Airborne") -- The whole flight group is airborne.
self:AddTransition("*", "FlightLanding", "Landing") -- The whole flight group is landing. self:AddTransition("*", "Landing", "Landing") -- The whole flight group is landing.
self:AddTransition("*", "FlightLanded", "Landed") -- The whole flight group has landed. self:AddTransition("*", "Landed", "Landed") -- The whole flight group has landed.
self:AddTransition("*", "FlightArrived", "Arrived") -- The whole flight group has arrived. self:AddTransition("*", "Arrived", "Arrived") -- The whole flight group has arrived.
------------------------ ------------------------
@ -1115,13 +1115,13 @@ function FLIGHTGROUP:OnEventEngineShutdown(EventData)
self:ElementArrived(element, airbase, parking) self:ElementArrived(element, airbase, parking)
self:T3(self.lid..string.format("EVENT: Element %s shut down engines ==> arrived", element.name)) self:T3(self.lid..string.format("EVENT: Element %s shut down engines ==> arrived", element.name))
else else
self:T3(self.lid..string.format("EVENT: Element %s shut down engines (in air) ==> dead", element.name)) self:T3(self.lid..string.format("EVENT: Element %s shut down engines but is not parking. Is it dead?", element.name))
self:ElementDead(element) --self:ElementDead(element)
end end
else 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 end
@ -1165,6 +1165,19 @@ function FLIGHTGROUP:OnEventUnitLost(EventData)
-- Check that this is the right group. -- Check that this is the right group.
if EventData and EventData.IniGroup and EventData.IniUnit and EventData.IniGroupName and EventData.IniGroupName==self.groupname then 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)) 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
end end
@ -1434,12 +1447,12 @@ function FLIGHTGROUP:onafterSpawned(From, Event, To)
end 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 #FLIGHTGROUP self
-- @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.
function FLIGHTGROUP:onafterFlightParking(From, Event, To) function FLIGHTGROUP:onafterParking(From, Event, To)
self:I(self.lid..string.format("Flight is parking")) self:I(self.lid..string.format("Flight is parking"))
local airbase=self.group:GetCoordinate():GetClosestAirbase() local airbase=self.group:GetCoordinate():GetClosestAirbase()
@ -1471,12 +1484,12 @@ function FLIGHTGROUP:onafterFlightParking(From, Event, To)
end end
end end
--- On after "FlightTaxiing" event. --- On after "Taxiing" event.
-- @param #FLIGHTGROUP self -- @param #FLIGHTGROUP self
-- @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.
function FLIGHTGROUP:onafterFlightTaxiing(From, Event, To) function FLIGHTGROUP:onafterTaxiing(From, Event, To)
self:T(self.lid..string.format("Flight is taxiing")) self:T(self.lid..string.format("Flight is taxiing"))
-- Parking over. -- Parking over.
@ -1502,13 +1515,13 @@ function FLIGHTGROUP:onafterFlightTaxiing(From, Event, To)
end end
--- On after "FlightTakeoff" event. --- On after "Takeoff" event.
-- @param #FLIGHTGROUP self -- @param #FLIGHTGROUP self
-- @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 Wrapper.Airbase#AIRBASE airbase The airbase the flight landed. -- @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")) self:T(self.lid..string.format("Flight takeoff from %s", airbase and airbase:GetName() or "unknown airbase"))
-- Remove flight from all FC queues. -- Remove flight from all FC queues.
@ -1519,12 +1532,12 @@ function FLIGHTGROUP:onafterFlightTakeoff(From, Event, To, airbase)
end end
--- On after "FlightAirborne" event. --- On after "Airborne" event.
-- @param #FLIGHTGROUP self -- @param #FLIGHTGROUP self
-- @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.
function FLIGHTGROUP:onafterFlightAirborne(From, Event, To) function FLIGHTGROUP:onafterAirborne(From, Event, To)
self:I(self.lid..string.format("Flight airborne")) self:I(self.lid..string.format("Flight airborne"))
if not self.ai then if not self.ai then
@ -1532,25 +1545,25 @@ function FLIGHTGROUP:onafterFlightAirborne(From, Event, To)
end end
end end
--- On after "FlightLanding" event. --- On after "Landing" event.
-- @param #FLIGHTGROUP self -- @param #FLIGHTGROUP self
-- @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.
function FLIGHTGROUP:onafterFlightLanding(From, Event, To) function FLIGHTGROUP:onafterLanding(From, Event, To)
self:T(self.lid..string.format("Flight is landing")) self:T(self.lid..string.format("Flight is landing"))
self:_SetElementStatusAll(OPSGROUP.ElementStatus.LANDING) self:_SetElementStatusAll(OPSGROUP.ElementStatus.LANDING)
end end
--- On after "FlightLanded" event. --- On after "Landed" event.
-- @param #FLIGHTGROUP self -- @param #FLIGHTGROUP self
-- @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 Wrapper.Airbase#AIRBASE airbase The airbase the flight landed. -- @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")) self:T(self.lid..string.format("Flight landed at %s", airbase and airbase:GetName() or "unknown place"))
if self:IsLandingAt() then if self:IsLandingAt() then
@ -1563,12 +1576,12 @@ function FLIGHTGROUP:onafterFlightLanded(From, Event, To, airbase)
end end
end end
--- On after "FlightArrived" event. --- On after "Arrived" event.
-- @param #FLIGHTGROUP self -- @param #FLIGHTGROUP self
-- @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.
function FLIGHTGROUP:onafterFlightArrived(From, Event, To) function FLIGHTGROUP:onafterArrived(From, Event, To)
self:T(self.lid..string.format("Flight arrived")) self:T(self.lid..string.format("Flight arrived"))
-- Flight Control -- Flight Control
@ -2445,8 +2458,8 @@ end
function FLIGHTGROUP._ClearedToLand(group, flightgroup) function FLIGHTGROUP._ClearedToLand(group, flightgroup)
flightgroup:I(flightgroup.lid..string.format("Group was cleared to land")) flightgroup:I(flightgroup.lid..string.format("Group was cleared to land"))
-- Trigger FlightLanding event. -- Trigger Landing event.
flightgroup:__FlightLanding(-1) flightgroup:__Landing(-1)
end end
--- Function called when flight finished refuelling. --- Function called when flight finished refuelling.

View File

@ -2452,7 +2452,7 @@ function OPSGROUP:_UpdateStatus(element, newstatus, airbase)
--- ---
if self:_AllSimilarStatus(newstatus) then if self:_AllSimilarStatus(newstatus) then
self:__FlightParking(-0.5) self:__Parking(-0.5)
end end
elseif newstatus==OPSGROUP.ElementStatus.ENGINEON then elseif newstatus==OPSGROUP.ElementStatus.ENGINEON then
@ -2468,7 +2468,7 @@ function OPSGROUP:_UpdateStatus(element, newstatus, airbase)
--- ---
if self:_AllSimilarStatus(newstatus) then if self:_AllSimilarStatus(newstatus) then
self:__FlightTaxiing(-0.5) self:__Taxiing(-0.5)
end end
elseif newstatus==OPSGROUP.ElementStatus.TAKEOFF then elseif newstatus==OPSGROUP.ElementStatus.TAKEOFF then
@ -2478,7 +2478,7 @@ function OPSGROUP:_UpdateStatus(element, newstatus, airbase)
if self:_AllSimilarStatus(newstatus) then if self:_AllSimilarStatus(newstatus) then
-- Trigger takeoff event. Also triggers airborne event. -- Trigger takeoff event. Also triggers airborne event.
self:__FlightTakeoff(-0.5, airbase) self:__Takeoff(-0.5, airbase)
end end
elseif newstatus==OPSGROUP.ElementStatus.AIRBORNE then elseif newstatus==OPSGROUP.ElementStatus.AIRBORNE then
@ -2487,7 +2487,7 @@ function OPSGROUP:_UpdateStatus(element, newstatus, airbase)
--- ---
if self:_AllSimilarStatus(newstatus) then if self:_AllSimilarStatus(newstatus) then
self:__FlightAirborne(-0.5) self:__Airborne(-0.5)
end end
elseif newstatus==OPSGROUP.ElementStatus.LANDED then elseif newstatus==OPSGROUP.ElementStatus.LANDED then
@ -2496,7 +2496,7 @@ function OPSGROUP:_UpdateStatus(element, newstatus, airbase)
--- ---
if self:_AllSimilarStatus(newstatus) then if self:_AllSimilarStatus(newstatus) then
self:FlightLanded(airbase) self:Landed(airbase)
end end
elseif newstatus==OPSGROUP.ElementStatus.ARRIVED then elseif newstatus==OPSGROUP.ElementStatus.ARRIVED then
@ -2507,10 +2507,10 @@ function OPSGROUP:_UpdateStatus(element, newstatus, airbase)
if self:_AllSimilarStatus(newstatus) then if self:_AllSimilarStatus(newstatus) then
if self:IsLanded() then if self:IsLanded() then
self:FlightArrived() self:Arrived()
elseif self:IsAirborne() then elseif self:IsAirborne() then
self:FlightLanded() self:Landed()
self:FlightArrived() self:Arrived()
end end
end end

View File

@ -1481,8 +1481,8 @@ end
-- @param #number WeaponType Bitmask of weapon types, which are allowed to use. -- @param #number WeaponType Bitmask of weapon types, which are allowed to use.
-- @param DCS#AI.Task.Designation Designation (Optional) Designation type. -- @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 #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 Frequency Frequency in MHz used to communicate with the FAC. Default 133 MHz.
-- @param #number Modulation Modulation of radio for communication. -- @param #number Modulation Modulation of radio for communication. Default 0=AM.
-- @param #number CallsignName Callsign enumerator name of the FAC. -- @param #number CallsignName Callsign enumerator name of the FAC.
-- @param #number CallsignNumber Callsign number, e.g. Axeman-**1**. -- @param #number CallsignNumber Callsign number, e.g. Axeman-**1**.
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
@ -1492,11 +1492,11 @@ function CONTROLLABLE:TaskFAC_AttackGroup( AttackGroup, WeaponType, Designation,
id = 'FAC_AttackGroup', id = 'FAC_AttackGroup',
params = { params = {
groupId = AttackGroup:GetID(), groupId = AttackGroup:GetID(),
weaponType = WeaponType, weaponType = WeaponType or ENUMS.WeaponFlag.AutoDCS,
designation = Designation, designation = Designation or "Auto",
datalink = Datalink, datalink = Datalink and Datalink or true,
frequency = Frequency, frequency = (Frequency or 133)*1000000,
modulation = Modulation, modulation = Modulation or radio.modulation.AM,
callname = CallsignName, callname = CallsignName,
number = CallsignNumber, number = CallsignNumber,
} }