mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge pull request #1319 from FlightControl-Master/FF/Develop
Ff/develop
This commit is contained in:
commit
5b514d223b
@ -240,23 +240,31 @@ end
|
||||
|
||||
--- Respawns the original @{Static}.
|
||||
-- @param #SPAWNSTATIC self
|
||||
-- @param #number delay Delay before respawn in seconds.
|
||||
-- @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 StaticUnitTemplate = StaticTemplate.units[1]
|
||||
StaticTemplate.route = nil
|
||||
StaticTemplate.groupId = nil
|
||||
local StaticTemplate, CoalitionID, CategoryID, CountryID = _DATABASE:GetStaticGroupTemplate( self.SpawnTemplatePrefix )
|
||||
|
||||
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
|
||||
|
||||
return nil
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
|
||||
@ -1764,7 +1764,7 @@ _WAREHOUSEDB = {
|
||||
|
||||
--- Warehouse class version.
|
||||
-- @field #string version
|
||||
WAREHOUSE.version="1.0.0"
|
||||
WAREHOUSE.version="1.0.1"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO: Warehouse todo list.
|
||||
@ -1870,6 +1870,12 @@ function WAREHOUSE:New(warehouse, alias)
|
||||
|
||||
-- Set unique ID for this warehouse.
|
||||
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.
|
||||
local _airbase=self:GetCoordinate():GetClosestAirbase(nil, self:GetCoalition())
|
||||
@ -3395,8 +3401,13 @@ end
|
||||
-- @param #string To To state.
|
||||
function WAREHOUSE:onafterStatus(From, Event, To)
|
||||
|
||||
local FSMstate=self:GetState()
|
||||
|
||||
local coalition=self:GetCoalitionName()
|
||||
local country=self:GetCountryName()
|
||||
|
||||
-- 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.
|
||||
self:_JobDone()
|
||||
@ -4944,6 +4955,21 @@ function WAREHOUSE:onafterDefeated(From, Event, To)
|
||||
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.
|
||||
-- @param #WAREHOUSE self
|
||||
@ -4967,34 +4993,17 @@ 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.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @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)
|
||||
|
||||
local CoalitionOld=self:GetCoalition()
|
||||
|
||||
-- Respawn warehouse with new coalition/country.
|
||||
self.warehouse:ReSpawn(Country)
|
||||
|
||||
local CoalitionNew=self:GetCoalition()
|
||||
@ -5002,23 +5011,23 @@ function WAREHOUSE:onafterChangeCountry(From, Event, To, Country)
|
||||
-- Delete all waiting requests because they are not valid any more.
|
||||
self.queue=nil
|
||||
self.queue={}
|
||||
|
||||
-- Airbase could have been captured before and already belongs to the new coalition.
|
||||
-- Check if Warehouse has a arbiase atthached
|
||||
local airbasecoaltion
|
||||
if self.airbase ~= nil then
|
||||
|
||||
if self.airbasename then
|
||||
|
||||
-- Get airbase of this warehouse.
|
||||
local airbase=AIRBASE:FindByName(self.airbasename)
|
||||
airbasecoaltion=airbase:GetCoalition()
|
||||
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.
|
||||
airbasecoaltion = 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
|
||||
|
||||
-- Get coalition of the airbase.
|
||||
local airbaseCoalition=airbase:GetCoalition()
|
||||
|
||||
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
|
||||
|
||||
end
|
||||
|
||||
-- Debug smoke.
|
||||
@ -5032,6 +5041,20 @@ function WAREHOUSE:onafterChangeCountry(From, Event, To, Country)
|
||||
|
||||
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.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param #string From From state.
|
||||
@ -5044,9 +5067,7 @@ function WAREHOUSE:onafterCaptured(From, Event, To, Coalition, Country)
|
||||
-- Message.
|
||||
local text=string.format("Warehouse %s: We were captured by enemy coalition (side=%d)!", self.alias, Coalition)
|
||||
self:_InfoMessage(text)
|
||||
|
||||
-- Warehouse respawned.
|
||||
self:ChangeCountry(Country)
|
||||
|
||||
end
|
||||
|
||||
|
||||
@ -8474,7 +8495,7 @@ function WAREHOUSE:_DebugMessage(text, duration)
|
||||
if duration>0 then
|
||||
MESSAGE:New(text, duration):ToAllIf(self.Debug)
|
||||
end
|
||||
self:I(self.lid..text)
|
||||
self:T(self.lid..text)
|
||||
end
|
||||
|
||||
--- Error message. Message send to all (if duration > 0). Text self:E(text) added to DCS.log file.
|
||||
|
||||
@ -1273,11 +1273,17 @@ AIRBOSS.AircraftCarrier={
|
||||
|
||||
--- Carrier types.
|
||||
-- @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 VINSON USS Carl Vinson (CVN-70)
|
||||
-- @field #string TARAWA USS Tarawa (LHA-1)
|
||||
-- @field #string KUZNETSOV Admiral Kuznetsov (CV 1143.5)
|
||||
AIRBOSS.CarrierType={
|
||||
ROOSEVELT="CVN_71",
|
||||
LINCOLN="CVN_72",
|
||||
WASHINGTON="CVN_73",
|
||||
STENNIS="Stennis",
|
||||
VINSON="VINSON",
|
||||
TARAWA="LHA_Tarawa",
|
||||
@ -1929,6 +1935,12 @@ function AIRBOSS:New(carriername, alias)
|
||||
-- Init carrier parameters.
|
||||
if self.carriertype==AIRBOSS.CarrierType.STENNIS then
|
||||
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
|
||||
-- TODO: Carl Vinson parameters.
|
||||
self:_InitStennis()
|
||||
|
||||
@ -238,7 +238,6 @@ ENUMS.FormationOld.FixedWing.SpreadFour=7
|
||||
ENUMS.FormationOld.FixedWing.BomberElement=12
|
||||
ENUMS.FormationOld.FixedWing.BomberElementHeight=13
|
||||
ENUMS.FormationOld.FixedWing.FighterVic=14
|
||||
ENUMS.FormationOld={}
|
||||
ENUMS.FormationOld.RotaryWing={}
|
||||
ENUMS.FormationOld.RotaryWing.Wedge=8
|
||||
ENUMS.FormationOld.RotaryWing.Echelon=9
|
||||
|
||||
@ -224,7 +224,7 @@ function STATIC:ReSpawn(countryid, Delay)
|
||||
else
|
||||
|
||||
local SpawnStatic = SPAWNSTATIC:NewFromStatic( self.StaticName, countryid )
|
||||
|
||||
|
||||
SpawnStatic:ReSpawn()
|
||||
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user