Ops - Various

This commit is contained in:
Applevangelist 2021-12-07 16:09:02 +01:00
parent 8d009d6366
commit 23ea5d9d06
4 changed files with 45 additions and 16 deletions

View File

@ -1626,6 +1626,7 @@ WAREHOUSE = {
-- @field #string spawngroupname Name of the spawned group.
-- @field #boolean iscargo If true, asset is cargo. If false asset is transport. Nil if in stock.
-- @field #boolean arrived If true, asset arrived at its destination.
-- @field Core.Point#COORDINATE spawncoordinate If set, spawn asst here and not in the designated spawn zone.
--
-- @field #number damage Damage of asset group in percent.
-- @field Ops.AirWing#AIRWING.Payload payload The payload of the asset.
@ -1795,7 +1796,7 @@ _WAREHOUSEDB = {
--- Warehouse class version.
-- @field #string version
WAREHOUSE.version="1.0.2"
WAREHOUSE.version="1.0.3"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO: Warehouse todo list.
@ -4249,9 +4250,11 @@ end
-- @param #number nTransport Number of transport units requested.
-- @param #number Prio Priority of the request. Number ranging from 1=high to 100=low.
-- @param #string Assignment A keyword or text that later be used to identify this request and postprocess the assets.
-- @param Core.Point#COORDINATE SpawnCoordinate Spawn group here instead of the SpawnZone.
-- @return #boolean If true, request is okay at first glance.
function WAREHOUSE:onbeforeAddRequest(From, Event, To, warehouse, AssetDescriptor, AssetDescriptorValue, nAsset, TransportType, nTransport, Assignment, Prio)
function WAREHOUSE:onbeforeAddRequest(From, Event, To, warehouse, AssetDescriptor, AssetDescriptorValue, nAsset, TransportType, nTransport, Assignment, Prio, SpawnCoordinate)
-- self:I({From, Event, To})
--self:I({SpawnCoordinate=SpawnCoordinate})
-- Request is okay.
local okay=true
@ -4344,8 +4347,10 @@ end
-- @param #number nTransport Number of transport units requested.
-- @param #number Prio Priority of the request. Number ranging from 1=high to 100=low.
-- @param #string Assignment A keyword or text that can later be used to identify this request and postprocess the assets.
function WAREHOUSE:onafterAddRequest(From, Event, To, warehouse, AssetDescriptor, AssetDescriptorValue, nAsset, TransportType, nTransport, Prio, Assignment)
-- @param Core.Point#COORDINATE SpawnCoordinate Spawn group here instead of the SpawnZone.
function WAREHOUSE:onafterAddRequest(From, Event, To, warehouse, AssetDescriptor, AssetDescriptorValue, nAsset, TransportType, nTransport, Prio, Assignment, SpawnCoordinate)
--self:I({From, Event, To})
--self:I({SpawnCoordinate=SpawnCoordinate})
-- Defaults.
nAsset=nAsset or 1
TransportType=TransportType or WAREHOUSE.TransportType.SELFPROPELLED
@ -4384,6 +4389,7 @@ function WAREHOUSE:onafterAddRequest(From, Event, To, warehouse, AssetDescriptor
ntransporthome=0,
assets={},
toself=toself,
spawncoordinate=SpawnCoordinate,
} --#WAREHOUSE.Queueitem
-- Add request to queue.
@ -5814,7 +5820,8 @@ end
-- @param #boolean lateactivated If true, groups are spawned late activated.
-- @return Wrapper.Group#GROUP The spawned group or nil if the group could not be spawned.
function WAREHOUSE:_SpawnAssetGroundNaval(alias, asset, request, spawnzone, lateactivated)
--self:I("_SpawnAssetGroundNaval - " .. tostring(asset.templatename))
--self:I({coordinate = request.spawncoordinate})
if asset and (asset.category==Group.Category.GROUND or asset.category==Group.Category.SHIP or asset.category==Group.Category.TRAIN) then
-- Prepare spawn template.
@ -5826,6 +5833,11 @@ function WAREHOUSE:_SpawnAssetGroundNaval(alias, asset, request, spawnzone, late
-- Get a random coordinate in the spawn zone.
local coord=spawnzone:GetRandomCoordinate()
-- Is a specific coordinate set?
if request.spawncoordinate then
coord = request.spawncoordinate
end
-- For trains, we use the rail connection point.
if asset.category==Group.Category.TRAIN then
coord=self.rail
@ -7642,7 +7654,7 @@ end
-- @param #WAREHOUSE self
-- @return #WAREHOUSE.Queueitem Chosen request.
function WAREHOUSE:_CheckQueue()
--self:T("_CheckQueue()")
-- Sort queue wrt to first prio and then qid.
self:_SortQueue()
@ -7680,7 +7692,13 @@ function WAREHOUSE:_CheckQueue()
self:_DeleteQueueItem(_request, self.queue)
end
-- Execute request.
--[[ Execute request.
if request and type(request) == "table" then
for _key,_value in pairs(request) do
self:I("Key = ".. tostring(_key))
end
end
--]]
return request
end

View File

@ -162,6 +162,8 @@
-- @field #number optionRTBfuel RTB on out-of-fuel.
-- @field #number optionECM ECM.
--
-- @field Core.Point#COORDINATE specialCoordinate Special point to reload Brigade units in place.
--
-- @extends Core.Fsm#FSM
--- *A warrior's mission is to foster the success of others.* - Morihei Ueshiba

View File

@ -324,7 +324,7 @@ function LEGION:AddMission(Mission)
-- Set target for ALERT 5.
if Mission.type==AUFTRAG.Type.ALERT5 then
Mission:_TargetFromObject(self:GetCoordinate())
--Mission:_TargetFromObject(self:GetCoordinate())
end
-- Add mission to queue.
@ -694,6 +694,10 @@ function LEGION:onafterMissionRequest(From, Event, To, Mission)
asset.flightgroup:MissionCancel(currM)
end
-- Cancel the current mission.
if currM and currM.type==AUFTRAG.Type.ONGUARD then
asset.flightgroup:MissionCancel(currM)
end
-- Trigger event.
self:__OpsOnMission(5, asset.flightgroup, Mission)
@ -721,18 +725,23 @@ function LEGION:onafterMissionRequest(From, Event, To, Mission)
asset.requested=true
asset.isReserved=false
-- Set missin task so that the group is spawned with the right one.
-- Set mission task so that the group is spawned with the right one.
if Mission.missionTask then
asset.missionTask=Mission.missionTask
end
end
local coordinate = nil
if Mission.specialCoordinate then
coordinate = Mission.specialCoordinate
end
-- TODO: Get/set functions for assignment string.
local assignment=string.format("Mission-%d", Mission.auftragsnummer)
-- Add request to legion warehouse.
self:AddRequest(self, WAREHOUSE.Descriptor.ASSETLIST, Assetlist, #Assetlist, nil, nil, Mission.prio, assignment)
self:AddRequest(self, WAREHOUSE.Descriptor.ASSETLIST, Assetlist, #Assetlist, nil, nil, Mission.prio, assignment, coordinate)
-- The queueid has been increased in the onafterAddRequest function. So we can simply use it here.
Mission.requestID[self.alias]=self.queueid

View File

@ -2159,7 +2159,7 @@ function UTILS.LoadSetOfGroups(Path,Filename,Spawn)
local posz = tonumber(dataset[6])
local coordinate = COORDINATE:NewFromVec3({x=posx, y=posy, z=posz})
local group=nil
local data = { groupname=groupname, size=size, coordinate=coordinate }
local data = { groupname=groupname, template=template, size=size, coordinate=coordinate }
table.insert(datatable,data)
if spawn then
local group = SPAWN:New(groupname)