Optimized the boarding and unboarding of cargo. fixed bug when in defence of APC, cargo would not be loaded. The boarding and unboarding has become much more stable now.

This commit is contained in:
FlightControl 2018-10-18 20:25:21 +02:00
parent ce9d1837a7
commit 90e7688cea

View File

@ -119,7 +119,6 @@ function AI_CARGO_APC:SetCarrier( CargoCarrier )
self.CargoCarrier:SetState( self.CargoCarrier, "AI_CARGO_APC", self ) self.CargoCarrier:SetState( self.CargoCarrier, "AI_CARGO_APC", self )
CargoCarrier:HandleEvent( EVENTS.Dead ) CargoCarrier:HandleEvent( EVENTS.Dead )
CargoCarrier:HandleEvent( EVENTS.Hit )
function CargoCarrier:OnEventDead( EventData ) function CargoCarrier:OnEventDead( EventData )
self:F({"dead"}) self:F({"dead"})
@ -134,17 +133,19 @@ function AI_CARGO_APC:SetCarrier( CargoCarrier )
end end
end end
function CargoCarrier:OnEventHit( EventData ) -- CargoCarrier:HandleEvent( EVENTS.Hit )
self:F({"hit"}) --
local AICargoTroops = self:GetState( self, "AI_CARGO_APC" ) -- function CargoCarrier:OnEventHit( EventData )
if AICargoTroops then -- self:F({"hit"})
self:F( { OnHitLoaded = AICargoTroops:Is( "Loaded" ) } ) -- local AICargoTroops = self:GetState( self, "AI_CARGO_APC" )
if AICargoTroops:Is( "Loaded" ) or AICargoTroops:Is( "Boarding" ) then -- if AICargoTroops then
-- There are enemies within combat radius. Unload the CargoCarrier. -- self:F( { OnHitLoaded = AICargoTroops:Is( "Loaded" ) } )
AICargoTroops:Unload( false ) -- if AICargoTroops:Is( "Loaded" ) or AICargoTroops:Is( "Boarding" ) then
end -- -- There are enemies within combat radius. Unload the CargoCarrier.
end -- AICargoTroops:Unload( false )
end -- end
-- end
-- end
self.Zone = ZONE_UNIT:New( self.CargoCarrier:GetName() .. "-Zone", self.CargoCarrier, self.CombatRadius ) self.Zone = ZONE_UNIT:New( self.CargoCarrier:GetName() .. "-Zone", self.CargoCarrier, self.CombatRadius )
self.Coalition = self.CargoCarrier:GetCoalition() self.Coalition = self.CargoCarrier:GetCoalition()