mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
DETECTION, SET, ARTY, WAREHOUSE, AIRBOSS, A2A_DISPATCHER
DETECTION - Fixed bug with late activated groups. ARTY v1.1.2 - Added attack group task for ships. - Added respawn option. WAREHOUSE v0.9.5 - Added respawn option. AIRBOSS v1.0.3 - Recovery time extended if flights are still in the pattern. SET - Added CountAlive() function. A2A_DISPATCHER - Bug fixes in :ParkDefender() function.
This commit is contained in:
@@ -77,6 +77,8 @@
|
||||
-- @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 #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.
|
||||
-- @extends Core.Fsm#FSM
|
||||
|
||||
--- Have your assets at the right place at the right time - or not!
|
||||
@@ -1569,6 +1571,8 @@ WAREHOUSE = {
|
||||
saveparking = false,
|
||||
isunit = false,
|
||||
lowfuelthresh = 0.15,
|
||||
respawnafterdestroyed=false,
|
||||
respawndelay = nil,
|
||||
}
|
||||
|
||||
--- Item of the warehouse stock table.
|
||||
@@ -1745,7 +1749,7 @@ _WAREHOUSEDB = {
|
||||
|
||||
--- Warehouse class version.
|
||||
-- @field #string version
|
||||
WAREHOUSE.version="0.9.4"
|
||||
WAREHOUSE.version="0.9.5"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO: Warehouse todo list.
|
||||
@@ -1908,6 +1912,7 @@ function WAREHOUSE:New(warehouse, alias)
|
||||
self:AddTransition("*", "AirbaseRecaptured", "*") -- Airbase was re-captured from other coalition.
|
||||
self:AddTransition("*", "AssetDead", "*") -- An asset group died.
|
||||
self:AddTransition("*", "Destroyed", "Destroyed") -- Warehouse was destroyed. All assets in stock are gone and warehouse is stopped.
|
||||
self:AddTransition("Destroyed", "Respawn", "Running") -- Respawn warehouse after it was destroyed.
|
||||
|
||||
------------------------
|
||||
--- Pseudo Functions ---
|
||||
@@ -1940,6 +1945,22 @@ function WAREHOUSE:New(warehouse, alias)
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param #number delay Delay in seconds.
|
||||
|
||||
--- Triggers the FSM event "Respawn".
|
||||
-- @function [parent=#WAREHOUSE] Respawn
|
||||
-- @param #WAREHOUSE self
|
||||
|
||||
--- Triggers the FSM event "Respawn" after a delay.
|
||||
-- @function [parent=#WAREHOUSE] __Respawn
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param #number delay Delay in seconds.
|
||||
|
||||
--- On after "Respawn" event user function.
|
||||
-- @function [parent=#WAREHOUSE] OnAfterRespawn
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
|
||||
--- Triggers the FSM event "Pause". Pauses the warehouse. Assets can still be added and requests be made. However, requests are not processed.
|
||||
-- @function [parent=#WAREHOUSE] Pause
|
||||
-- @param #WAREHOUSE self
|
||||
@@ -2533,6 +2554,15 @@ function WAREHOUSE:SetSaveOnMissionEnd(path, filename)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set respawn after destroy.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @return #WAREHOUSE self
|
||||
function WAREHOUSE:SetRespawnAfterDestroyed(delay)
|
||||
self.respawnafterdestroyed=true
|
||||
self.respawndelay=delay
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set the airbase belonging to this warehouse.
|
||||
-- Note that it has to be of the same coalition as the warehouse.
|
||||
@@ -3960,7 +3990,7 @@ function WAREHOUSE:onbeforeAddRequest(From, Event, To, warehouse, AssetDescripto
|
||||
end
|
||||
|
||||
-- Warehouse is destroyed?
|
||||
if self:IsDestroyed() then
|
||||
if self:IsDestroyed() and not self.respawnafterdestroyed then
|
||||
self:_ErrorMessage("ERROR: Invalid request. Warehouse is destroyed!", 0)
|
||||
okay=false
|
||||
end
|
||||
@@ -4827,6 +4857,21 @@ function WAREHOUSE:onbeforeChangeCountry(From, Event, To, Country)
|
||||
return false
|
||||
end
|
||||
|
||||
--- Respawn warehouse.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
function WAREHOUSE:onafterRespawn(From, Event, To)
|
||||
|
||||
-- Info message.
|
||||
local text=string.format("Respawning warehouse %s.", self.alias)
|
||||
self:_InfoMessage(text)
|
||||
|
||||
-- Respawn warehouse.
|
||||
self.warehouse:ReSpawn()
|
||||
|
||||
end
|
||||
|
||||
--- On after "ChangeCountry" event. Warehouse is respawned with the specified country. All queued requests are deleted and the owned airbase is reset if the coalition is changed by changing the
|
||||
-- country.
|
||||
@@ -4963,22 +5008,34 @@ end
|
||||
function WAREHOUSE:onafterDestroyed(From, Event, To)
|
||||
|
||||
-- Message.
|
||||
local text=string.format("Warehouse %s was destroyed! Assets lost %d.", self.alias, #self.stock)
|
||||
local text=string.format("Warehouse %s was destroyed! Assets lost %d. Respawn=%s", self.alias, #self.stock, tostring(self.respawnafterdestroyed))
|
||||
self:_InfoMessage(text)
|
||||
|
||||
-- Remove all table entries from waiting queue and stock.
|
||||
for k,_ in pairs(self.queue) do
|
||||
self.queue[k]=nil
|
||||
if self.respawnafterdestroyed then
|
||||
|
||||
if self.respawndelay then
|
||||
self:Pause()
|
||||
self:__Respawn(self.respawndelay)
|
||||
else
|
||||
self:Respawn()
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
-- Remove all table entries from waiting queue and stock.
|
||||
for k,_ in pairs(self.queue) do
|
||||
self.queue[k]=nil
|
||||
end
|
||||
for k,_ in pairs(self.stock) do
|
||||
self.stock[k]=nil
|
||||
end
|
||||
|
||||
--self.queue=nil
|
||||
--self.queue={}
|
||||
|
||||
--self.stock=nil
|
||||
--self.stock={}
|
||||
end
|
||||
for k,_ in pairs(self.stock) do
|
||||
self.stock[k]=nil
|
||||
end
|
||||
|
||||
--self.queue=nil
|
||||
--self.queue={}
|
||||
|
||||
--self.stock=nil
|
||||
--self.stock={}
|
||||
|
||||
end
|
||||
|
||||
@@ -6343,7 +6400,7 @@ function WAREHOUSE:_CheckRequestConsistancy(queue)
|
||||
end
|
||||
|
||||
-- Is receiving warehouse destroyed?
|
||||
if request.warehouse:IsDestroyed() then
|
||||
if request.warehouse:IsDestroyed() and not self.respawnafterdestroyed then
|
||||
self:E(self.wid..string.format("ERROR: INVALID request. Requesting warehouse is destroyed!"))
|
||||
valid=false
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user