mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
@@ -349,7 +349,6 @@ RANGE.Defaults={
|
||||
boxlength=3000,
|
||||
boxwidth=300,
|
||||
goodpass=20,
|
||||
goodhitrange=25,
|
||||
foulline=610,
|
||||
}
|
||||
|
||||
@@ -2570,7 +2569,7 @@ function RANGE:_DisplayBombTargets(_unitname)
|
||||
end
|
||||
end
|
||||
|
||||
self:_DisplayMessageToGroup(_unit,_text, 60, true, true)
|
||||
self:_DisplayMessageToGroup(_unit,_text, 120, true, true)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -80,12 +80,14 @@
|
||||
-- @field #string autosavepath Path where the asset file is saved on auto save.
|
||||
-- @field #string autosavefile File name of the auto asset save file. Default is auto generated from warehouse id and name.
|
||||
-- @field #boolean safeparking If true, parking spots for aircraft are considered as occupied if e.g. a client aircraft is parked there. Default false.
|
||||
-- @field #boolean isunit If true, warehouse is represented by a unit instead of a static.
|
||||
-- @field #boolean isUnit If `true`, warehouse is represented by a unit instead of a static.
|
||||
-- @field #boolean isShip If `true`, warehouse is represented by a ship unit.
|
||||
-- @field #number lowfuelthresh Low fuel threshold. Triggers the event AssetLowFuel if for any unit fuel goes below this number.
|
||||
-- @field #boolean respawnafterdestroyed If true, warehouse is respawned after it was destroyed. Assets are kept.
|
||||
-- @field #number respawndelay Delay before respawn in seconds.
|
||||
-- @field #number runwaydestroyed Time stamp timer.getAbsTime() when the runway was destroyed.
|
||||
-- @field #number runwayrepairtime Time in seconds until runway will be repaired after it was destroyed. Default is 3600 sec (one hour).
|
||||
-- @field Ops.FlightControl#FLIGHTCONTROL flightcontrol Flight control of this warehouse.
|
||||
-- @extends Core.Fsm#FSM
|
||||
|
||||
--- Have your assets at the right place at the right time - or not!
|
||||
@@ -1590,7 +1592,8 @@ WAREHOUSE = {
|
||||
autosavepath = nil,
|
||||
autosavefile = nil,
|
||||
saveparking = false,
|
||||
isunit = false,
|
||||
isUnit = false,
|
||||
isShip = false,
|
||||
lowfuelthresh = 0.15,
|
||||
respawnafterdestroyed=false,
|
||||
respawndelay = nil,
|
||||
@@ -1599,6 +1602,8 @@ WAREHOUSE = {
|
||||
--- Item of the warehouse stock table.
|
||||
-- @type WAREHOUSE.Assetitem
|
||||
-- @field #number uid Unique id of the asset.
|
||||
-- @field #number wid ID of the warehouse this asset belongs to.
|
||||
-- @field #number rid Request ID of this asset (if any).
|
||||
-- @field #string templatename Name of the template group.
|
||||
-- @field #table template The spawn template of the group.
|
||||
-- @field DCS#Group.Category category Category of the group.
|
||||
@@ -1620,9 +1625,17 @@ WAREHOUSE = {
|
||||
-- @field #boolean spawned If true, asset was spawned into the cruel world. If false, it is still in stock.
|
||||
-- @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 #number rid The request ID of this asset.
|
||||
-- @field #boolean arrived If true, asset arrived at its destination.
|
||||
--
|
||||
-- @field #number damage Damage of asset group in percent.
|
||||
-- @field Ops.AirWing#AIRWING.Payload payload The payload of the asset.
|
||||
-- @field Ops.OpsGroup#OPSGROUP flightgroup The flightgroup object.
|
||||
-- @field Ops.Cohort#COHORT cohort The cohort this asset belongs to.
|
||||
-- @field Ops.Legion#LEGION legion The legion this asset belonts to.
|
||||
-- @field #string squadname Name of the squadron this asset belongs to.
|
||||
-- @field #number Treturned Time stamp when asset returned to its legion (airwing, brigade).
|
||||
-- @field #boolean requested If `true`, asset was requested and cannot be selected by another request.
|
||||
-- @field #boolean isReserved If `true`, asset was reserved and cannot be selected by another request.
|
||||
|
||||
--- Item of the warehouse queue table.
|
||||
-- @type WAREHOUSE.Queueitem
|
||||
@@ -1645,6 +1658,7 @@ WAREHOUSE = {
|
||||
-- @field #table transportassets Table of transport carrier assets. Each element of the table is a @{#WAREHOUSE.Assetitem}.
|
||||
-- @field #number transportattribute Attribute of transport assets of type @{#WAREHOUSE.Attribute}.
|
||||
-- @field #number transportcategory Category of transport assets of type @{#WAREHOUSE.Category}.
|
||||
-- @field #boolean lateActivation Assets are spawned in late activated state.
|
||||
|
||||
--- Item of the warehouse pending queue table.
|
||||
-- @type WAREHOUSE.Pendingitem
|
||||
@@ -1842,40 +1856,50 @@ WAREHOUSE.version="1.0.2"
|
||||
|
||||
--- The WAREHOUSE constructor. Creates a new WAREHOUSE object from a static object. Parameters like the coalition and country are taken from the static object structure.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param Wrapper.Static#STATIC warehouse The physical structure representing the warehouse.
|
||||
-- @param #string alias (Optional) Alias of the warehouse, i.e. the name it will be called when sending messages etc. Default is the name of the static
|
||||
-- @param Wrapper.Static#STATIC warehouse The physical structure representing the warehouse. Can also be a @{Wrapper.Unit#UNIT}.
|
||||
-- @param #string alias (Optional) Alias of the warehouse, i.e. the name it will be called when sending messages etc. Default is the name of the static/unit representing the warehouse.
|
||||
-- @return #WAREHOUSE self
|
||||
function WAREHOUSE:New(warehouse, alias)
|
||||
|
||||
-- Inherit everthing from FSM class.
|
||||
local self=BASE:Inherit(self, FSM:New()) -- #WAREHOUSE
|
||||
|
||||
-- Check if just a string was given and convert to static.
|
||||
if type(warehouse)=="string" then
|
||||
local warehousename=warehouse
|
||||
local warehousename=warehouse
|
||||
warehouse=UNIT:FindByName(warehousename)
|
||||
if warehouse==nil then
|
||||
warehouse=STATIC:FindByName(warehousename, true)
|
||||
self.isunit=false
|
||||
else
|
||||
self.isunit=true
|
||||
end
|
||||
end
|
||||
|
||||
-- Nil check.
|
||||
if warehouse==nil then
|
||||
BASE:E("ERROR: Warehouse does not exist!")
|
||||
env.error("ERROR: Warehouse does not exist!")
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Check if we have a STATIC or UNIT object.
|
||||
if warehouse:IsInstanceOf("STATIC") then
|
||||
self.isUnit=false
|
||||
elseif warehouse:IsInstanceOf("UNIT") then
|
||||
self.isUnit=true
|
||||
if warehouse:IsShip() then
|
||||
self.isShip=true
|
||||
end
|
||||
else
|
||||
env.error("ERROR: Warehouse is neither STATIC nor UNIT object!")
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Set alias.
|
||||
self.alias=alias or warehouse:GetName()
|
||||
|
||||
-- Print version.
|
||||
env.info(string.format("Adding warehouse v%s for structure %s with alias %s", WAREHOUSE.version, warehouse:GetName(), self.alias))
|
||||
|
||||
-- Inherit everthing from FSM class.
|
||||
local self=BASE:Inherit(self, FSM:New()) -- #WAREHOUSE
|
||||
|
||||
-- Set some string id for output to DCS.log file.
|
||||
self.lid=string.format("WAREHOUSE %s | ", self.alias)
|
||||
|
||||
-- Print version.
|
||||
self:I(self.lid..string.format("Adding warehouse v%s for structure %s [isUnit=%s, isShip=%s]", WAREHOUSE.version, warehouse:GetName(), tostring(self:IsUnit()), tostring(self:IsShip())))
|
||||
|
||||
-- Set some variables.
|
||||
self.warehouse=warehouse
|
||||
@@ -1899,14 +1923,19 @@ function WAREHOUSE:New(warehouse, alias)
|
||||
end
|
||||
|
||||
-- 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)
|
||||
if self.isShip then
|
||||
self.zone=ZONE_AIRBASE:New(self.warehouse:GetName(), 1000)
|
||||
self.spawnzone=ZONE_AIRBASE:New(self.warehouse:GetName(), 1000)
|
||||
else
|
||||
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)
|
||||
end
|
||||
|
||||
|
||||
-- Defaults
|
||||
self:SetMarker(true)
|
||||
self:SetReportOff()
|
||||
self:SetRunwayRepairtime()
|
||||
--self:SetVerbosityLevel(0)
|
||||
|
||||
-- Add warehouse to database.
|
||||
_WAREHOUSEDB.Warehouses[self.uid]=self
|
||||
@@ -2590,6 +2619,12 @@ function WAREHOUSE:SetSpawnZone(zone, maxdist)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Get the spawn zone.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @return Core.Zone#ZONE The spawn zone.
|
||||
function WAREHOUSE:GetSpawnZone()
|
||||
return self.spawnzone
|
||||
end
|
||||
|
||||
--- Set a warehouse zone. If this zone is captured, the warehouse and all its assets fall into the hands of the enemy.
|
||||
-- @param #WAREHOUSE self
|
||||
@@ -2631,9 +2666,8 @@ end
|
||||
--- Check parking ID.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param Wrapper.Airbase#AIRBASE.ParkingSpot spot Parking spot.
|
||||
-- @param Wrapper.Airbase#AIRBASE airbase The airbase.
|
||||
-- @return #boolean If true, parking is valid.
|
||||
function WAREHOUSE:_CheckParkingValid(spot, airbase)
|
||||
function WAREHOUSE:_CheckParkingValid(spot)
|
||||
|
||||
if self.parkingIDs==nil then
|
||||
return true
|
||||
@@ -2648,6 +2682,25 @@ function WAREHOUSE:_CheckParkingValid(spot, airbase)
|
||||
return false
|
||||
end
|
||||
|
||||
--- Check parking ID for an asset.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param Wrapper.Airbase#AIRBASE.ParkingSpot spot Parking spot.
|
||||
-- @return #boolean If true, parking is valid.
|
||||
function WAREHOUSE:_CheckParkingAsset(spot, asset)
|
||||
|
||||
if asset.parkingIDs==nil then
|
||||
return true
|
||||
end
|
||||
|
||||
for _,id in pairs(asset.parkingIDs or {}) do
|
||||
if spot.TerminalID==id then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
--- Enable auto save of warehouse assets at mission end event.
|
||||
-- @param #WAREHOUSE self
|
||||
@@ -3088,14 +3141,16 @@ end
|
||||
-- @param #WAREHOUSE self
|
||||
-- @return DCS#Vec3 The 3D vector of the warehouse.
|
||||
function WAREHOUSE:GetVec3()
|
||||
return self.warehouse:GetVec3()
|
||||
local vec3=self.warehouse:GetVec3()
|
||||
return vec3
|
||||
end
|
||||
|
||||
--- Get 2D vector of warehouse static.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @return DCS#Vec2 The 2D vector of the warehouse.
|
||||
function WAREHOUSE:GetVec2()
|
||||
return self.warehouse:GetVec2()
|
||||
local vec2=self.warehouse:GetVec2()
|
||||
return vec2
|
||||
end
|
||||
|
||||
|
||||
@@ -3164,18 +3219,6 @@ function WAREHOUSE:GetAssignment(request)
|
||||
return tostring(request.assignment)
|
||||
end
|
||||
|
||||
--[[
|
||||
--- Get warehouse unique ID from static warehouse object. This is the ID under which you find the @{#WAREHOUSE} object in the global data base.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param #string staticname Name of the warehouse static object.
|
||||
-- @return #number Warehouse unique ID.
|
||||
function WAREHOUSE:GetWarehouseID(staticname)
|
||||
local warehouse=STATIC:FindByName(staticname, true)
|
||||
local uid=tonumber(warehouse:GetID())
|
||||
return uid
|
||||
end
|
||||
]]
|
||||
|
||||
--- Find a warehouse in the global warehouse data base.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param #number uid The unique ID of the warehouse.
|
||||
@@ -3291,7 +3334,7 @@ end
|
||||
|
||||
--- Check if runway is operational.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @return #boolean If true, runway is operational.
|
||||
-- @return #boolean If `true`, runway is operational.
|
||||
function WAREHOUSE:IsRunwayOperational()
|
||||
if self.airbase then
|
||||
if self.runwaydestroyed then
|
||||
@@ -3327,6 +3370,27 @@ function WAREHOUSE:GetRunwayRepairtime()
|
||||
return 0
|
||||
end
|
||||
|
||||
--- Check if warehouse physical representation is a unit (not a static) object.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @return #boolean If `true`, warehouse object is a unit.
|
||||
function WAREHOUSE:IsUnit()
|
||||
return self.isUnit
|
||||
end
|
||||
|
||||
--- Check if warehouse physical representation is a static (not a unit) object.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @return #boolean If `true`, warehouse object is a static.
|
||||
function WAREHOUSE:IsStatic()
|
||||
return not self.isUnit
|
||||
end
|
||||
|
||||
--- Check if warehouse physical representation is a ship.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @return #boolean If `true`, warehouse object is a ship.
|
||||
function WAREHOUSE:IsShip()
|
||||
return self.isShip
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- FSM states
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -3537,7 +3601,7 @@ function WAREHOUSE:onafterStatus(From, Event, To)
|
||||
self:_PrintQueue(self.pending, "Queue pending")
|
||||
|
||||
-- Check fuel for all assets.
|
||||
self:_CheckFuel()
|
||||
--self:_CheckFuel()
|
||||
|
||||
-- Update warhouse marker on F10 map.
|
||||
self:_UpdateWarehouseMarkText()
|
||||
@@ -3921,6 +3985,8 @@ function WAREHOUSE:onafterAddAsset(From, Event, To, group, ngroups, forceattribu
|
||||
|
||||
-- Asset is not spawned.
|
||||
asset.spawned=false
|
||||
asset.requested=false
|
||||
asset.isReserved=false
|
||||
asset.iscargo=nil
|
||||
asset.arrived=nil
|
||||
|
||||
@@ -3971,9 +4037,21 @@ function WAREHOUSE:onafterAddAsset(From, Event, To, group, ngroups, forceattribu
|
||||
-- Destroy group if it is alive.
|
||||
if group:IsAlive()==true then
|
||||
self:_DebugMessage(string.format("Removing group %s", group:GetName()), 5)
|
||||
-- Setting parameter to false, i.e. creating NO dead or remove unit event, seems to not confuse the dispatcher logic.
|
||||
-- TODO: It would be nice, however, to have the remove event.
|
||||
group:Destroy() --(false)
|
||||
|
||||
local opsgroup=_DATABASE:GetOpsGroup(group:GetName())
|
||||
if opsgroup then
|
||||
opsgroup:Despawn(0, true)
|
||||
opsgroup:__Stop(-0.01)
|
||||
else
|
||||
-- Setting parameter to false, i.e. creating NO dead or remove unit event, seems to not confuse the dispatcher logic.
|
||||
-- TODO: It would be nice, however, to have the remove event.
|
||||
group:Destroy() --(false)
|
||||
end
|
||||
else
|
||||
local opsgroup=_DATABASE:GetOpsGroup(group:GetName())
|
||||
if opsgroup then
|
||||
opsgroup:Stop()
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
@@ -4099,6 +4177,8 @@ function WAREHOUSE:_RegisterAsset(group, ngroups, forceattribute, forcecargobay,
|
||||
asset.skill=skill
|
||||
asset.assignment=assignment
|
||||
asset.spawned=false
|
||||
asset.requested=false
|
||||
asset.isReserved=false
|
||||
asset.life0=group:GetLife0()
|
||||
asset.damage=0
|
||||
asset.spawngroupname=string.format("%s_AID-%d", templategroupname, asset.uid)
|
||||
@@ -4350,7 +4430,7 @@ function WAREHOUSE:onbeforeRequest(From, Event, To, Request)
|
||||
|
||||
-- Delete request from queue because it will never be possible.
|
||||
-- Unless(!) at least one is a moving warehouse, which could, e.g., be an aircraft carrier.
|
||||
if not (self.isunit or Request.warehouse.isunit) then
|
||||
if not (self.isUnit or Request.warehouse.isUnit) then
|
||||
self:_DeleteQueueItem(Request, self.queue)
|
||||
end
|
||||
|
||||
@@ -4467,6 +4547,11 @@ function WAREHOUSE:onafterRequest(From, Event, To, Request)
|
||||
return
|
||||
end
|
||||
|
||||
-- Trigger event.
|
||||
if spawngroup then
|
||||
self:__AssetSpawned(0.01, spawngroup, _assetitem, Request)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Init problem table.
|
||||
@@ -4883,6 +4968,13 @@ function WAREHOUSE:onbeforeArrived(From, Event, To, group)
|
||||
local asset=self:FindAssetInDB(group)
|
||||
|
||||
if asset then
|
||||
|
||||
if asset.flightgroup and not asset.arrived then
|
||||
--env.info("FF asset has a flightgroup. arrival will be handled there!")
|
||||
asset.arrived=true
|
||||
return false
|
||||
end
|
||||
|
||||
if asset.arrived==true then
|
||||
-- Asset already arrived (e.g. if multiple units trigger the event via landing).
|
||||
return false
|
||||
@@ -4890,6 +4982,7 @@ function WAREHOUSE:onbeforeArrived(From, Event, To, group)
|
||||
asset.arrived=true --ensure this is not called again from the same asset group.
|
||||
return true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -5288,24 +5381,6 @@ function WAREHOUSE:onafterRunwayRepaired(From, Event, To)
|
||||
end
|
||||
|
||||
|
||||
--- 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.
|
||||
-- @param #string To To state.
|
||||
-- @param Wrapper.Group#GROUP group The group spawned.
|
||||
-- @param #WAREHOUSE.Assetitem asset The asset that is dead.
|
||||
-- @param #WAREHOUSE.Pendingitem request The request of the dead asset.
|
||||
function WAREHOUSE:onbeforeAssetSpawned(From, Event, To, group, asset, request)
|
||||
if asset.spawned then
|
||||
--return false
|
||||
else
|
||||
--return true
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
--- On after "AssetSpawned" event triggered when an asset group is spawned into the cruel world.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param #string From From state.
|
||||
@@ -5320,6 +5395,24 @@ function WAREHOUSE:onafterAssetSpawned(From, Event, To, group, asset, request)
|
||||
|
||||
-- Sete asset state to spawned.
|
||||
asset.spawned=true
|
||||
|
||||
-- Set spawn group name.
|
||||
asset.spawngroupname=group:GetName()
|
||||
|
||||
-- Remove asset from stock.
|
||||
self:_DeleteStockItem(asset)
|
||||
|
||||
-- Add group.
|
||||
if asset.iscargo==true then
|
||||
request.cargogroupset=request.cargogroupset or SET_GROUP:New()
|
||||
request.cargogroupset:AddGroup(group)
|
||||
else
|
||||
request.transportgroupset=request.transportgroupset or SET_GROUP:New()
|
||||
request.transportgroupset:AddGroup(group)
|
||||
end
|
||||
|
||||
-- Set warehouse state.
|
||||
group:SetState(group, "WAREHOUSE", self)
|
||||
|
||||
-- Check if all assets groups are spawned and trigger events.
|
||||
local n=0
|
||||
@@ -5670,15 +5763,15 @@ function WAREHOUSE:_SpawnAssetRequest(Request)
|
||||
if asset.category==Group.Category.GROUND then
|
||||
|
||||
-- Spawn ground troops.
|
||||
_group=self:_SpawnAssetGroundNaval(_alias, asset, Request, self.spawnzone)
|
||||
_group=self:_SpawnAssetGroundNaval(_alias, asset, Request, self.spawnzone, Request.lateActivation)
|
||||
|
||||
elseif asset.category==Group.Category.AIRPLANE or asset.category==Group.Category.HELICOPTER then
|
||||
|
||||
-- Spawn air units.
|
||||
if Parking[asset.uid] then
|
||||
_group=self:_SpawnAssetAircraft(_alias, asset, Request, Parking[asset.uid], UnControlled)
|
||||
_group=self:_SpawnAssetAircraft(_alias, asset, Request, Parking[asset.uid], UnControlled, Request.lateActivation)
|
||||
else
|
||||
_group=self:_SpawnAssetAircraft(_alias, asset, Request, nil, UnControlled)
|
||||
_group=self:_SpawnAssetAircraft(_alias, asset, Request, nil, UnControlled, Request.lateActivation)
|
||||
end
|
||||
|
||||
elseif asset.category==Group.Category.TRAIN then
|
||||
@@ -5688,7 +5781,7 @@ function WAREHOUSE:_SpawnAssetRequest(Request)
|
||||
--TODO: Rail should only get one asset because they would spawn on top!
|
||||
|
||||
-- Spawn naval assets.
|
||||
_group=self:_SpawnAssetGroundNaval(_alias, asset, Request, self.spawnzone)
|
||||
_group=self:_SpawnAssetGroundNaval(_alias, asset, Request, self.spawnzone, Request.lateActivation)
|
||||
end
|
||||
|
||||
--self:E(self.lid.."ERROR: Spawning of TRAIN assets not possible yet!")
|
||||
@@ -5696,11 +5789,16 @@ function WAREHOUSE:_SpawnAssetRequest(Request)
|
||||
elseif asset.category==Group.Category.SHIP then
|
||||
|
||||
-- Spawn naval assets.
|
||||
_group=self:_SpawnAssetGroundNaval(_alias, asset, Request, self.portzone)
|
||||
_group=self:_SpawnAssetGroundNaval(_alias, asset, Request, self.portzone, Request.lateActivation)
|
||||
|
||||
else
|
||||
self:E(self.lid.."ERROR: Unknown asset category!")
|
||||
end
|
||||
|
||||
-- Trigger event.
|
||||
if _group then
|
||||
self:__AssetSpawned(0.01, _group, asset, Request)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -5713,9 +5811,9 @@ end
|
||||
-- @param #WAREHOUSE.Assetitem asset Ground asset that will be spawned.
|
||||
-- @param #WAREHOUSE.Queueitem request Request belonging to this asset. Needed for the name/alias.
|
||||
-- @param Core.Zone#ZONE spawnzone Zone where the assets should be spawned.
|
||||
-- @param #boolean aioff If true, AI of ground units are set to off.
|
||||
-- @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, aioff)
|
||||
function WAREHOUSE:_SpawnAssetGroundNaval(alias, asset, request, spawnzone, lateactivated)
|
||||
|
||||
if asset and (asset.category==Group.Category.GROUND or asset.category==Group.Category.SHIP or asset.category==Group.Category.TRAIN) then
|
||||
|
||||
@@ -5758,6 +5856,9 @@ function WAREHOUSE:_SpawnAssetGroundNaval(alias, asset, request, spawnzone, aiof
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Late activation.
|
||||
template.lateActivation=lateactivated
|
||||
|
||||
template.route.points[1].x = coord.x
|
||||
template.route.points[1].y = coord.z
|
||||
@@ -5769,14 +5870,6 @@ function WAREHOUSE:_SpawnAssetGroundNaval(alias, asset, request, spawnzone, aiof
|
||||
-- Spawn group.
|
||||
local group=_DATABASE:Spawn(template) --Wrapper.Group#GROUP
|
||||
|
||||
-- Activate group. Should only be necessary for late activated groups.
|
||||
--group:Activate()
|
||||
|
||||
-- Switch AI off if desired. This works only for ground and naval groups.
|
||||
if aioff then
|
||||
group:SetAIOff()
|
||||
end
|
||||
|
||||
return group
|
||||
end
|
||||
|
||||
@@ -5790,8 +5883,9 @@ end
|
||||
-- @param #WAREHOUSE.Queueitem request Request belonging to this asset. Needed for the name/alias.
|
||||
-- @param #table parking Parking data for this asset.
|
||||
-- @param #boolean uncontrolled Spawn aircraft in uncontrolled state.
|
||||
-- @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:_SpawnAssetAircraft(alias, asset, request, parking, uncontrolled)
|
||||
function WAREHOUSE:_SpawnAssetAircraft(alias, asset, request, parking, uncontrolled, lateactivated)
|
||||
|
||||
if asset and asset.category==Group.Category.AIRPLANE or asset.category==Group.Category.HELICOPTER then
|
||||
|
||||
@@ -6043,18 +6137,10 @@ function WAREHOUSE:_RouteGround(group, request)
|
||||
end
|
||||
|
||||
for n,wp in ipairs(Waypoints) do
|
||||
env.info(n)
|
||||
local tf=self:_SimpleTaskFunctionWP("warehouse:_PassingWaypoint",group, n, #Waypoints)
|
||||
group:SetTaskWaypoint(wp, tf)
|
||||
end
|
||||
|
||||
-- Task function triggering the arrived event at the last waypoint.
|
||||
--local TaskFunction = self:_SimpleTaskFunction("warehouse:_Arrived", group)
|
||||
|
||||
-- Put task function on last waypoint.
|
||||
--local Waypoint = Waypoints[#Waypoints]
|
||||
--group:SetTaskWaypoint(Waypoint, TaskFunction)
|
||||
|
||||
-- Route group to destination.
|
||||
group:Route(Waypoints, 1)
|
||||
|
||||
@@ -6132,9 +6218,11 @@ function WAREHOUSE:_RouteAir(aircraft)
|
||||
self:T2(self.lid..string.format("RouteAir aircraft group %s alive=%s", aircraft:GetName(), tostring(aircraft:IsAlive())))
|
||||
|
||||
-- Give start command to activate uncontrolled aircraft within the next 60 seconds.
|
||||
local starttime=math.random(60)
|
||||
if not self.flightcontrol then
|
||||
local starttime=math.random(60)
|
||||
|
||||
aircraft:StartUncontrolled(starttime)
|
||||
aircraft:StartUncontrolled(starttime)
|
||||
end
|
||||
|
||||
-- Debug info.
|
||||
self:T2(self.lid..string.format("RouteAir aircraft group %s alive=%s (after start command)", aircraft:GetName(), tostring(aircraft:IsAlive())))
|
||||
@@ -6281,41 +6369,12 @@ function WAREHOUSE:_OnEventBirth(EventData)
|
||||
local request=self:GetRequestByID(rid)
|
||||
|
||||
if asset and request then
|
||||
|
||||
|
||||
-- Debug message.
|
||||
self:T(self.lid..string.format("Warehouse %s captured event birth of request ID=%d, asset ID=%d, unit %s spawned=%s", self.alias, request.uid, asset.uid, EventData.IniUnitName, tostring(asset.spawned)))
|
||||
|
||||
-- Set born to true.
|
||||
request.born=true
|
||||
|
||||
-- Birth is triggered for each unit. We need to make sure not to call this too often!
|
||||
if not asset.spawned then
|
||||
|
||||
-- Remove asset from stock.
|
||||
self:_DeleteStockItem(asset)
|
||||
|
||||
-- Set spawned switch.
|
||||
asset.spawned=true
|
||||
asset.spawngroupname=group:GetName()
|
||||
|
||||
-- Add group.
|
||||
if asset.iscargo==true then
|
||||
request.cargogroupset=request.cargogroupset or SET_GROUP:New()
|
||||
request.cargogroupset:AddGroup(group)
|
||||
else
|
||||
request.transportgroupset=request.transportgroupset or SET_GROUP:New()
|
||||
request.transportgroupset:AddGroup(group)
|
||||
end
|
||||
|
||||
-- Set warehouse state.
|
||||
group:SetState(group, "WAREHOUSE", self)
|
||||
|
||||
-- Asset spawned FSM function.
|
||||
--self:__AssetSpawned(1, group, asset, request)
|
||||
--env.info(string.format("FF asset spawned %s, %s", asset.spawngroupname, EventData.IniUnitName))
|
||||
self:AssetSpawned(group, asset, request)
|
||||
|
||||
end
|
||||
|
||||
else
|
||||
self:E(self.lid..string.format("ERROR: Either asset AID=%s or request RID=%s are nil in event birth of unit %s", tostring(aid), tostring(rid), tostring(EventData.IniUnitName)))
|
||||
@@ -7016,10 +7075,9 @@ function WAREHOUSE:_CheckRequestValid(request)
|
||||
-- Check that both spawn zones are not in water.
|
||||
local inwater=self.spawnzone:GetCoordinate():IsSurfaceTypeWater() or request.warehouse.spawnzone:GetCoordinate():IsSurfaceTypeWater()
|
||||
|
||||
if inwater then
|
||||
if inwater and not request.lateActivation then
|
||||
self:E("ERROR: Incorrect request. Ground asset requested but at least one spawn zone is in water!")
|
||||
--valid=false
|
||||
valid=false
|
||||
return false
|
||||
end
|
||||
|
||||
-- No ground assets directly to or from ships.
|
||||
@@ -7641,7 +7699,7 @@ function WAREHOUSE:_SimpleTaskFunction(Function, group)
|
||||
local DCSScript = {}
|
||||
|
||||
DCSScript[#DCSScript+1] = string.format('local mygroup = GROUP:FindByName(\"%s\") ', groupname) -- The group that executes the task function. Very handy with the "...".
|
||||
if self.isunit then
|
||||
if self.isUnit then
|
||||
DCSScript[#DCSScript+1] = string.format("local mywarehouse = UNIT:FindByName(\"%s\") ", warehouse) -- The unit that holds the warehouse self object.
|
||||
else
|
||||
DCSScript[#DCSScript+1] = string.format("local mywarehouse = STATIC:FindByName(\"%s\") ", warehouse) -- The static that holds the warehouse self object.
|
||||
@@ -7672,7 +7730,7 @@ function WAREHOUSE:_SimpleTaskFunctionWP(Function, group, n, N)
|
||||
local DCSScript = {}
|
||||
|
||||
DCSScript[#DCSScript+1] = string.format('local mygroup = GROUP:FindByName(\"%s\") ', groupname) -- The group that executes the task function. Very handy with the "...".
|
||||
if self.isunit then
|
||||
if self.isUnit then
|
||||
DCSScript[#DCSScript+1] = string.format("local mywarehouse = UNIT:FindByName(\"%s\") ", warehouse) -- The unit that holds the warehouse self object.
|
||||
else
|
||||
DCSScript[#DCSScript+1] = string.format("local mywarehouse = STATIC:FindByName(\"%s\") ", warehouse) -- The static that holds the warehouse self object.
|
||||
@@ -7841,7 +7899,7 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets)
|
||||
local parkingspot=_parkingspot --Wrapper.Airbase#AIRBASE.ParkingSpot
|
||||
|
||||
-- Check correct terminal type for asset. We don't want helos in shelters etc.
|
||||
if AIRBASE._CheckTerminalType(parkingspot.TerminalType, terminaltype) and self:_CheckParkingValid(parkingspot, airbase) and airbase:_CheckParkingLists(parkingspot.TerminalID) then
|
||||
if AIRBASE._CheckTerminalType(parkingspot.TerminalType, terminaltype) and self:_CheckParkingValid(parkingspot) and self:_CheckParkingAsset(parkingspot, asset) and airbase:_CheckParkingLists(parkingspot.TerminalID) then
|
||||
|
||||
-- Coordinate of the parking spot.
|
||||
local _spot=parkingspot.Coordinate -- Core.Point#COORDINATE
|
||||
@@ -8045,10 +8103,10 @@ function WAREHOUSE:_GetIDsFromGroup(group)
|
||||
end
|
||||
|
||||
-- Debug info
|
||||
self:T(self.lid..string.format("Group Name = %s", tostring(name)))
|
||||
self:T(self.lid..string.format("Warehouse ID = %s", tostring(wid)))
|
||||
self:T(self.lid..string.format("Asset ID = %s", tostring(aid)))
|
||||
self:T(self.lid..string.format("Request ID = %s", tostring(rid)))
|
||||
self:T3(self.lid..string.format("Group Name = %s", tostring(name)))
|
||||
self:T3(self.lid..string.format("Warehouse ID = %s", tostring(wid)))
|
||||
self:T3(self.lid..string.format("Asset ID = %s", tostring(aid)))
|
||||
self:T3(self.lid..string.format("Request ID = %s", tostring(rid)))
|
||||
|
||||
return wid,aid,rid
|
||||
else
|
||||
@@ -8740,7 +8798,7 @@ end
|
||||
-- @param #number duration Message display duration in seconds. Default 20 sec. If duration is zero, no message is displayed.
|
||||
function WAREHOUSE:_DebugMessage(text, duration)
|
||||
duration=duration or 20
|
||||
if duration>0 then
|
||||
if self.Debug and duration>0 then
|
||||
MESSAGE:New(text, duration):ToAllIf(self.Debug)
|
||||
end
|
||||
self:T(self.lid..text)
|
||||
@@ -9047,11 +9105,11 @@ function WAREHOUSE:_GetFlightplan(asset, departure, destination)
|
||||
|
||||
-- Hot start.
|
||||
if asset.takeoffType and asset.takeoffType==COORDINATE.WaypointType.TakeOffParkingHot then
|
||||
env.info("FF hot")
|
||||
--env.info("FF hot")
|
||||
_type=COORDINATE.WaypointType.TakeOffParkingHot
|
||||
_action=COORDINATE.WaypointAction.FromParkingAreaHot
|
||||
else
|
||||
env.info("FF cold")
|
||||
--env.info("FF cold")
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user