This commit is contained in:
Frank 2020-05-03 01:14:37 +02:00
parent 5b03bc5066
commit 77de1dda2b
2 changed files with 47 additions and 22 deletions

View File

@ -4944,6 +4944,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
@ -4967,22 +4982,6 @@ 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
@ -4995,7 +4994,7 @@ function WAREHOUSE:onafterChangeCountry(From, Event, To, Country)
local CoalitionOld=self:GetCoalition() local CoalitionOld=self:GetCoalition()
-- Respawn warehouse with new coalition/country. -- Respawn warehouse with new coalition/country.
self.warehouse:ReSpawn(Country) self:Respawn(Country)
local CoalitionNew=self:GetCoalition() local CoalitionNew=self:GetCoalition()
@ -5003,11 +5002,13 @@ function WAREHOUSE:onafterChangeCountry(From, Event, To, Country)
self.queue=nil self.queue=nil
self.queue={} self.queue={}
-- Get airbase of this warehouse.
local airbase=AIRBASE:FindByName(self.airbasename)
-- Airbase could have been captured before and already belongs to the new coalition. -- Airbase could have been captured before and already belongs to the new coalition.
-- Check if Warehouse has a arbiase atthached -- Check if Warehouse has a arbiase atthached
local airbasecoaltion local airbasecoaltion
if self.airbase~=nil then if self.airbase~=nil then
local airbase=AIRBASE:FindByName(self.airbasename)
airbasecoaltion=airbase:GetCoalition() 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. 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 airbasecoaltion = nil
@ -5032,6 +5033,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.
@ -5045,8 +5060,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

View File

@ -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()