mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-20 17:07:54 +00:00
Merge branch 'FF/Develop' into FF/Fox2
This commit is contained in:
@@ -240,23 +240,31 @@ end
|
|||||||
|
|
||||||
--- Respawns the original @{Static}.
|
--- Respawns the original @{Static}.
|
||||||
-- @param #SPAWNSTATIC self
|
-- @param #SPAWNSTATIC self
|
||||||
|
-- @param #number delay Delay before respawn in seconds.
|
||||||
-- @return #SPAWNSTATIC
|
-- @return #SPAWNSTATIC
|
||||||
function SPAWNSTATIC:ReSpawn()
|
function SPAWNSTATIC:ReSpawn(delay)
|
||||||
|
|
||||||
local StaticTemplate, CoalitionID, CategoryID, CountryID = _DATABASE:GetStaticGroupTemplate( self.SpawnTemplatePrefix )
|
if delay and delay>0 then
|
||||||
|
self:ScheduleOnce(delay, SPAWNSTATIC.ReSpawn, self)
|
||||||
|
else
|
||||||
|
|
||||||
if StaticTemplate then
|
local StaticTemplate, CoalitionID, CategoryID, CountryID = _DATABASE:GetStaticGroupTemplate( self.SpawnTemplatePrefix )
|
||||||
|
|
||||||
local StaticUnitTemplate = StaticTemplate.units[1]
|
|
||||||
StaticTemplate.route = nil
|
|
||||||
StaticTemplate.groupId = nil
|
|
||||||
|
|
||||||
local Static = coalition.addStaticObject( self.CountryID or CountryID, StaticTemplate.units[1] )
|
if StaticTemplate then
|
||||||
|
|
||||||
|
local StaticUnitTemplate = StaticTemplate.units[1]
|
||||||
|
StaticTemplate.route = nil
|
||||||
|
StaticTemplate.groupId = nil
|
||||||
|
|
||||||
|
local Static = coalition.addStaticObject( self.CountryID or CountryID, StaticTemplate.units[1] )
|
||||||
|
|
||||||
|
return _DATABASE:FindStatic(Static:getName())
|
||||||
|
end
|
||||||
|
|
||||||
return _DATABASE:FindStatic(Static:getName())
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1766,7 +1766,7 @@ _WAREHOUSEDB = {
|
|||||||
|
|
||||||
--- Warehouse class version.
|
--- Warehouse class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
WAREHOUSE.version="1.0.0"
|
WAREHOUSE.version="1.0.1"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO: Warehouse todo list.
|
-- TODO: Warehouse todo list.
|
||||||
@@ -1873,6 +1873,12 @@ 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.
|
||||||
|
self.coalition=self.warehouse:GetCoalition()
|
||||||
|
|
||||||
|
-- Country of the warehouse.
|
||||||
|
self.countryid=self.warehouse:GetCountry()
|
||||||
|
|
||||||
-- Closest of the same coalition but within 5 km range.
|
-- Closest of the same coalition but within 5 km range.
|
||||||
local _airbase=self:GetCoordinate():GetClosestAirbase(nil, self:GetCoalition())
|
local _airbase=self:GetCoordinate():GetClosestAirbase(nil, self:GetCoalition())
|
||||||
if _airbase and _airbase:GetCoordinate():Get2DDistance(self:GetCoordinate()) <= 5000 then
|
if _airbase and _airbase:GetCoordinate():Get2DDistance(self:GetCoordinate()) <= 5000 then
|
||||||
@@ -3395,8 +3401,13 @@ end
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function WAREHOUSE:onafterStatus(From, Event, To)
|
function WAREHOUSE:onafterStatus(From, Event, To)
|
||||||
|
|
||||||
|
local FSMstate=self:GetState()
|
||||||
|
|
||||||
|
local coalition=self:GetCoalitionName()
|
||||||
|
local country=self:GetCountryName()
|
||||||
|
|
||||||
-- Info.
|
-- Info.
|
||||||
self:I(self.lid..string.format("State=%s, Assets=%d, Requests: waiting=%d, pending=%d", self:GetState(), #self.stock, #self.queue, #self.pending))
|
self:I(self.lid..string.format("State=%s %s [%s]: Assets=%d, Requests: waiting=%d, pending=%d", FSMstate, country, coalition, #self.stock, #self.queue, #self.pending))
|
||||||
|
|
||||||
-- Check if any pending jobs are done and can be deleted from the queue.
|
-- Check if any pending jobs are done and can be deleted from the queue.
|
||||||
self:_JobDone()
|
self:_JobDone()
|
||||||
@@ -4947,6 +4958,21 @@ function WAREHOUSE:onafterDefeated(From, Event, To)
|
|||||||
end
|
end
|
||||||
end
|
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 before "ChangeCountry" event. Checks whether a change of country is necessary by comparing the actual country to the the requested one.
|
--- On before "ChangeCountry" event. Checks whether a change of country is necessary by comparing the actual country to the the requested one.
|
||||||
-- @param #WAREHOUSE self
|
-- @param #WAREHOUSE self
|
||||||
@@ -4970,34 +4996,17 @@ function WAREHOUSE:onbeforeChangeCountry(From, Event, To, Country)
|
|||||||
return false
|
return false
|
||||||
end
|
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
|
--- 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.
|
-- country.
|
||||||
-- @param #WAREHOUSE self
|
-- @param #WAREHOUSE 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 DCS#country.id Country which has captured the warehouse.
|
-- @param DCS#country.id Country Country which has captured the warehouse.
|
||||||
function WAREHOUSE:onafterChangeCountry(From, Event, To, Country)
|
function WAREHOUSE:onafterChangeCountry(From, Event, To, Country)
|
||||||
|
|
||||||
local CoalitionOld=self:GetCoalition()
|
local CoalitionOld=self:GetCoalition()
|
||||||
|
|
||||||
-- Respawn warehouse with new coalition/country.
|
|
||||||
self.warehouse:ReSpawn(Country)
|
self.warehouse:ReSpawn(Country)
|
||||||
|
|
||||||
local CoalitionNew=self:GetCoalition()
|
local CoalitionNew=self:GetCoalition()
|
||||||
@@ -5006,22 +5015,22 @@ function WAREHOUSE:onafterChangeCountry(From, Event, To, Country)
|
|||||||
self.queue=nil
|
self.queue=nil
|
||||||
self.queue={}
|
self.queue={}
|
||||||
|
|
||||||
-- Airbase could have been captured before and already belongs to the new coalition.
|
if self.airbasename then
|
||||||
-- Check if Warehouse has a arbiase atthached
|
|
||||||
local airbasecoaltion
|
-- Get airbase of this warehouse.
|
||||||
if self.airbase ~= nil then
|
local airbase=AIRBASE:FindByName(self.airbasename)
|
||||||
local airbase=AIRBASE:FindByName(self.airbasename)
|
|
||||||
airbasecoaltion=airbase:GetCoalition()
|
-- Get coalition of the airbase.
|
||||||
else -- Warehouse has no airbase attached so just keep whatever, self.airbase will still be nil since CoalitionNew will not be nil if Warehouse have a airbse attacjed.
|
local airbaseCoalition=airbase:GetCoalition()
|
||||||
airbasecoaltion = nil
|
|
||||||
end
|
if CoalitionNew==airbaseCoalition then
|
||||||
|
-- Airbase already owned by the coalition that captured the warehouse. Airbase can be used by this warehouse.
|
||||||
|
self.airbase=airbase
|
||||||
|
else
|
||||||
|
-- Airbase is owned by other coalition. So this warehouse does not have an airbase until it is captured.
|
||||||
|
self.airbase=nil
|
||||||
|
end
|
||||||
|
|
||||||
if CoalitionNew==airbasecoaltion then
|
|
||||||
-- Airbase already owned by the coalition that captured the warehouse. Airbase can be used by this warehouse.
|
|
||||||
self.airbase=airbase
|
|
||||||
else
|
|
||||||
-- Airbase is owned by other coalition. So this warehouse does not have an airbase unil it is captured.
|
|
||||||
self.airbase=nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Debug smoke.
|
-- Debug smoke.
|
||||||
@@ -5035,6 +5044,20 @@ function WAREHOUSE:onafterChangeCountry(From, Event, To, Country)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- On before "Captured" event. Warehouse has been captured by another coalition.
|
||||||
|
-- @param #WAREHOUSE self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
-- @param DCS#coalition.side Coalition which captured the warehouse.
|
||||||
|
-- @param DCS#country.id Country which has captured the warehouse.
|
||||||
|
function WAREHOUSE:onbeforeCaptured(From, Event, To, Coalition, Country)
|
||||||
|
|
||||||
|
-- Warehouse respawned.
|
||||||
|
self:ChangeCountry(Country)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
--- On after "Captured" event. Warehouse has been captured by another coalition.
|
--- On after "Captured" event. Warehouse has been captured by another coalition.
|
||||||
-- @param #WAREHOUSE self
|
-- @param #WAREHOUSE self
|
||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
@@ -5048,8 +5071,6 @@ function WAREHOUSE:onafterCaptured(From, Event, To, Coalition, Country)
|
|||||||
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)
|
||||||
|
|
||||||
-- Warehouse respawned.
|
|
||||||
self:ChangeCountry(Country)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -5646,7 +5667,7 @@ function WAREHOUSE:_SpawnAssetAircraft(alias, asset, request, parking, uncontrol
|
|||||||
|
|
||||||
-- Check enough parking spots.
|
-- Check enough parking spots.
|
||||||
if AirbaseCategory==Airbase.Category.HELIPAD then
|
if AirbaseCategory==Airbase.Category.HELIPAD then
|
||||||
|
|
||||||
elseif AirbaseCategory==Airbase.Category.SHIP then
|
elseif AirbaseCategory==Airbase.Category.SHIP then
|
||||||
|
|
||||||
--TODO Figure out what's necessary in this case.
|
--TODO Figure out what's necessary in this case.
|
||||||
@@ -6107,14 +6128,14 @@ function WAREHOUSE:_OnEventBirth(EventData)
|
|||||||
|
|
||||||
-- 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
|
||||||
|
|
||||||
-- Remove asset from stock.
|
-- Remove asset from stock.
|
||||||
self:_DeleteStockItem(asset)
|
self:_DeleteStockItem(asset)
|
||||||
|
|
||||||
-- Set spawned switch.
|
-- Set spawned switch.
|
||||||
asset.spawned=true
|
asset.spawned=true
|
||||||
asset.spawngroupname=group:GetName()
|
asset.spawngroupname=group:GetName()
|
||||||
|
|
||||||
-- Add group.
|
-- Add group.
|
||||||
if asset.iscargo==true then
|
if asset.iscargo==true then
|
||||||
request.cargogroupset=request.cargogroupset or SET_GROUP:New()
|
request.cargogroupset=request.cargogroupset or SET_GROUP:New()
|
||||||
@@ -6123,15 +6144,15 @@ function WAREHOUSE:_OnEventBirth(EventData)
|
|||||||
request.transportgroupset=request.transportgroupset or SET_GROUP:New()
|
request.transportgroupset=request.transportgroupset or SET_GROUP:New()
|
||||||
request.transportgroupset:AddGroup(group)
|
request.transportgroupset:AddGroup(group)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set warehouse state.
|
-- Set warehouse state.
|
||||||
group:SetState(group, "WAREHOUSE", self)
|
group:SetState(group, "WAREHOUSE", self)
|
||||||
|
|
||||||
-- Asset spawned FSM function. We delay this a bit to have all units of the group in the game.
|
-- Asset spawned FSM function. We delay this a bit to have all units of the group in the game.
|
||||||
self:__AssetSpawned(1, group, asset, request)
|
self:__AssetSpawned(1, group, asset, request)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
-- No request?!
|
-- No request?!
|
||||||
self:E(self.lid..string.format("ERROR: Could not get request when asset spawned! FF investigate! Unit name=%s asset spawed=%s", EventData.IniUnitName, tostring(asset.spawned)))
|
self:E(self.lid..string.format("ERROR: Could not get request when asset spawned! FF investigate! Unit name=%s asset spawed=%s", EventData.IniUnitName, tostring(asset.spawned)))
|
||||||
@@ -7518,7 +7539,7 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets)
|
|||||||
end
|
end
|
||||||
return coords
|
return coords
|
||||||
end
|
end
|
||||||
|
|
||||||
if airbase:GetAirbaseCategory()==Airbase.Category.SHIP then
|
if airbase:GetAirbaseCategory()==Airbase.Category.SHIP then
|
||||||
-- Scan a radius of 100 meters around the spot.
|
-- Scan a radius of 100 meters around the spot.
|
||||||
local _,_,_,units=airbase:GetCoordinate():ScanObjects(200, true, false, false)
|
local _,_,_,units=airbase:GetCoordinate():ScanObjects(200, true, false, false)
|
||||||
|
|||||||
@@ -1273,11 +1273,17 @@ AIRBOSS.AircraftCarrier={
|
|||||||
|
|
||||||
--- Carrier types.
|
--- Carrier types.
|
||||||
-- @type AIRBOSS.CarrierType
|
-- @type AIRBOSS.CarrierType
|
||||||
|
-- @field #string ROOSEVELT USS Theodore Roosevelt (CVN-71)
|
||||||
|
-- @field #string LINCOLN USS Abraham Lincoln (CVN-72)
|
||||||
|
-- @field #string WASHINGTON USS George Washington (CVN-73)
|
||||||
-- @field #string STENNIS USS John C. Stennis (CVN-74)
|
-- @field #string STENNIS USS John C. Stennis (CVN-74)
|
||||||
-- @field #string VINSON USS Carl Vinson (CVN-70)
|
-- @field #string VINSON USS Carl Vinson (CVN-70)
|
||||||
-- @field #string TARAWA USS Tarawa (LHA-1)
|
-- @field #string TARAWA USS Tarawa (LHA-1)
|
||||||
-- @field #string KUZNETSOV Admiral Kuznetsov (CV 1143.5)
|
-- @field #string KUZNETSOV Admiral Kuznetsov (CV 1143.5)
|
||||||
AIRBOSS.CarrierType={
|
AIRBOSS.CarrierType={
|
||||||
|
ROOSEVELT="CVN_71",
|
||||||
|
LINCOLN="CVN_72",
|
||||||
|
WASHINGTON="CVN_73",
|
||||||
STENNIS="Stennis",
|
STENNIS="Stennis",
|
||||||
VINSON="VINSON",
|
VINSON="VINSON",
|
||||||
TARAWA="LHA_Tarawa",
|
TARAWA="LHA_Tarawa",
|
||||||
@@ -1929,6 +1935,12 @@ function AIRBOSS:New(carriername, alias)
|
|||||||
-- Init carrier parameters.
|
-- Init carrier parameters.
|
||||||
if self.carriertype==AIRBOSS.CarrierType.STENNIS then
|
if self.carriertype==AIRBOSS.CarrierType.STENNIS then
|
||||||
self:_InitStennis()
|
self:_InitStennis()
|
||||||
|
elseif self.carriertype==AIRBOSS.CarrierType.ROOSEVELT then
|
||||||
|
self:_InitStennis()
|
||||||
|
elseif self.carriertype==AIRBOSS.CarrierType.LINCOLN then
|
||||||
|
self:_InitStennis()
|
||||||
|
elseif self.carriertype==AIRBOSS.CarrierType.WASHINGTON then
|
||||||
|
self:_InitStennis()
|
||||||
elseif self.carriertype==AIRBOSS.CarrierType.VINSON then
|
elseif self.carriertype==AIRBOSS.CarrierType.VINSON then
|
||||||
-- TODO: Carl Vinson parameters.
|
-- TODO: Carl Vinson parameters.
|
||||||
self:_InitStennis()
|
self:_InitStennis()
|
||||||
|
|||||||
@@ -238,7 +238,6 @@ ENUMS.FormationOld.FixedWing.SpreadFour=7
|
|||||||
ENUMS.FormationOld.FixedWing.BomberElement=12
|
ENUMS.FormationOld.FixedWing.BomberElement=12
|
||||||
ENUMS.FormationOld.FixedWing.BomberElementHeight=13
|
ENUMS.FormationOld.FixedWing.BomberElementHeight=13
|
||||||
ENUMS.FormationOld.FixedWing.FighterVic=14
|
ENUMS.FormationOld.FixedWing.FighterVic=14
|
||||||
ENUMS.FormationOld={}
|
|
||||||
ENUMS.FormationOld.RotaryWing={}
|
ENUMS.FormationOld.RotaryWing={}
|
||||||
ENUMS.FormationOld.RotaryWing.Wedge=8
|
ENUMS.FormationOld.RotaryWing.Wedge=8
|
||||||
ENUMS.FormationOld.RotaryWing.Echelon=9
|
ENUMS.FormationOld.RotaryWing.Echelon=9
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ function STATIC:ReSpawn(countryid, Delay)
|
|||||||
else
|
else
|
||||||
|
|
||||||
local SpawnStatic = SPAWNSTATIC:NewFromStatic( self.StaticName, countryid )
|
local SpawnStatic = SPAWNSTATIC:NewFromStatic( self.StaticName, countryid )
|
||||||
|
|
||||||
SpawnStatic:ReSpawn()
|
SpawnStatic:ReSpawn()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user