mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Merge pull request #1022 from FlightControl-Master/FF/Develop
Warehouse v0.6.1
This commit is contained in:
commit
016e59860f
@ -54,6 +54,7 @@
|
|||||||
-- @field #table shippinglanes Table holding the user defined shipping between warehouses.
|
-- @field #table shippinglanes Table holding the user defined shipping between warehouses.
|
||||||
-- @field #table offroadpaths Table holding user defined paths from one warehouse to another.
|
-- @field #table offroadpaths Table holding user defined paths from one warehouse to another.
|
||||||
-- @field #boolean autodefence When the warehouse is under attack, automatically spawn assets to defend the warehouse.
|
-- @field #boolean autodefence When the warehouse is under attack, automatically spawn assets to defend the warehouse.
|
||||||
|
-- @field #number spawnzonemaxdist Max distance between warehouse and spawn zone. Default 5000 meters.
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
--- Have your assets at the right place at the right time - or not!
|
--- Have your assets at the right place at the right time - or not!
|
||||||
@ -1474,7 +1475,8 @@ WAREHOUSE = {
|
|||||||
portzone = nil,
|
portzone = nil,
|
||||||
shippinglanes = {},
|
shippinglanes = {},
|
||||||
offroadpaths = {},
|
offroadpaths = {},
|
||||||
autodefence = false,
|
autodefence = false,
|
||||||
|
spawnzonemaxdist = 5000,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Item of the warehouse stock table.
|
--- Item of the warehouse stock table.
|
||||||
@ -1645,7 +1647,7 @@ WAREHOUSE.db = {
|
|||||||
|
|
||||||
--- Warehouse class version.
|
--- Warehouse class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
WAREHOUSE.version="0.6.0"
|
WAREHOUSE.version="0.6.1"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO: Warehouse todo list.
|
-- TODO: Warehouse todo list.
|
||||||
@ -2214,12 +2216,15 @@ end
|
|||||||
--- Set a zone where the (ground) assets of the warehouse are spawned once requested.
|
--- Set a zone where the (ground) assets of the warehouse are spawned once requested.
|
||||||
-- @param #WAREHOUSE self
|
-- @param #WAREHOUSE self
|
||||||
-- @param Core.Zone#ZONE zone The spawn zone.
|
-- @param Core.Zone#ZONE zone The spawn zone.
|
||||||
|
-- @param #number maxdist (Optional) Maximum distance in meters between spawn zone and warehouse. Units are not spawned if distance is larger. Default is 5000 m.
|
||||||
-- @return #WAREHOUSE self
|
-- @return #WAREHOUSE self
|
||||||
function WAREHOUSE:SetSpawnZone(zone)
|
function WAREHOUSE:SetSpawnZone(zone, maxdist)
|
||||||
self.spawnzone=zone
|
self.spawnzone=zone
|
||||||
|
self.spawnzonemaxdist=maxdist or 5000
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set a warehouse zone. If this zone is captured, the warehouse and all its assets fall into the hands of the enemy.
|
--- 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
|
-- @param #WAREHOUSE self
|
||||||
-- @param Core.Zone#ZONE zone The warehouse zone. Note that this **cannot** be a polygon zone!
|
-- @param Core.Zone#ZONE zone The warehouse zone. Note that this **cannot** be a polygon zone!
|
||||||
@ -2723,10 +2728,11 @@ end
|
|||||||
-- @param MinAssets (Optional) Minimum number of assets the warehouse should have. Default 0.
|
-- @param MinAssets (Optional) Minimum number of assets the warehouse should have. Default 0.
|
||||||
-- @param #string Descriptor (Optional) Descriptor describing the selected assets which should be in stock. See @{#WAREHOUSE.Descriptor} for possible values.
|
-- @param #string Descriptor (Optional) Descriptor describing the selected assets which should be in stock. See @{#WAREHOUSE.Descriptor} for possible values.
|
||||||
-- @param DescriptorValue (Optional) Descriptor value selecting the type of assets which should be in stock.
|
-- @param DescriptorValue (Optional) Descriptor value selecting the type of assets which should be in stock.
|
||||||
-- @param DCS#Coalition.side Coalition (Optional) Coalition side of the warehouse. Default is the same coaliton as the present warehouse. Set to false for any coalition.
|
-- @param DCS#Coalition.side Coalition (Optional) Coalition side of the warehouse. Default is the same coaliton as the present warehouse. Set to false for any coalition.
|
||||||
|
-- @param Core.Point#COORDINATE RefCoordinate (Optional) Coordinate to which the closest warehouse is searched. Default is the warehouse calling this function.
|
||||||
-- @return #WAREHOUSE The the nearest warehouse object. Or nil if no warehouse is found.
|
-- @return #WAREHOUSE The the nearest warehouse object. Or nil if no warehouse is found.
|
||||||
-- @return #number The distance to the nearest warehouse in meters. Or nil if no warehouse is found.
|
-- @return #number The distance to the nearest warehouse in meters. Or nil if no warehouse is found.
|
||||||
function WAREHOUSE:FindNearestWarehouse(MinAssets, Descriptor, DescriptorValue, Coalition)
|
function WAREHOUSE:FindNearestWarehouse(MinAssets, Descriptor, DescriptorValue, Coalition, RefCoordinate)
|
||||||
|
|
||||||
-- Defaults
|
-- Defaults
|
||||||
if Descriptor~=nil and DescriptorValue~=nil then
|
if Descriptor~=nil and DescriptorValue~=nil then
|
||||||
@ -2744,11 +2750,15 @@ function WAREHOUSE:FindNearestWarehouse(MinAssets, Descriptor, DescriptorValue,
|
|||||||
-- Nothing to do
|
-- Nothing to do
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Coalition=self:GetCoalition()
|
if self~=nil then
|
||||||
|
Coalition=self:GetCoalition()
|
||||||
|
else
|
||||||
|
anycoalition=true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Coordinate of this warehouse.
|
-- Coordinate of this warehouse or user specified reference.
|
||||||
local coord=self:GetCoordinate()
|
local coord=RefCoordinate or self:GetCoordinate()
|
||||||
|
|
||||||
-- Loop over all warehouses.
|
-- Loop over all warehouses.
|
||||||
local nearest=nil
|
local nearest=nil
|
||||||
@ -2756,11 +2766,10 @@ function WAREHOUSE:FindNearestWarehouse(MinAssets, Descriptor, DescriptorValue,
|
|||||||
for wid,warehouse in pairs(WAREHOUSE.db.Warehouses) do
|
for wid,warehouse in pairs(WAREHOUSE.db.Warehouses) do
|
||||||
local warehouse=warehouse --#WAREHOUSE
|
local warehouse=warehouse --#WAREHOUSE
|
||||||
|
|
||||||
-- Check that it is not the same warehouse.
|
-- Distance from this warehouse to the other warehouse.
|
||||||
if warehouse.uid ~= self.uid then
|
local dist=coord:Get2DDistance(warehouse:GetCoordinate())
|
||||||
|
|
||||||
-- Distance from this warehouse to the other warehouse.
|
if dist>0 then
|
||||||
local dist=coord:Get2DDistance(warehouse:GetCoordinate())
|
|
||||||
|
|
||||||
-- Check if coalition is right.
|
-- Check if coalition is right.
|
||||||
local samecoalition=anycoalition or Coalition==warehouse:GetCoalition()
|
local samecoalition=anycoalition or Coalition==warehouse:GetCoalition()
|
||||||
@ -6124,9 +6133,9 @@ function WAREHOUSE:_CheckRequestNow(request)
|
|||||||
local dist=self.warehouse:GetCoordinate():Get2DDistance(self.spawnzone:GetCoordinate())
|
local dist=self.warehouse:GetCoordinate():Get2DDistance(self.spawnzone:GetCoordinate())
|
||||||
|
|
||||||
-- Check min dist to spawn zone.
|
-- Check min dist to spawn zone.
|
||||||
if dist>5000 then
|
if dist>self.spawnzonemaxdist then
|
||||||
-- Not close enough to spawn zone.
|
-- Not close enough to spawn zone.
|
||||||
local text=string.format("Warehouse %s: Request denied! Not close enough to spawn zone. Distance = %d m. We need to be at least within 5000 m range to spawn.", self.alias, dist)
|
local text=string.format("Warehouse %s: Request denied! Not close enough to spawn zone. Distance = %d m. We need to be at least within %d m range to spawn.", self.alias, dist, self.spawnzonemaxdist)
|
||||||
self:_InfoMessage(text, 5)
|
self:_InfoMessage(text, 5)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user