Fixed the out of fuel bug.

This commit is contained in:
FlightControl 2018-10-26 12:08:48 +02:00
parent 17ffc7cef9
commit f0b5ec1025

View File

@ -439,12 +439,13 @@ function AI_A2A:onafterStatus()
end end
end end
if self:Is( "Fuel" ) or self:Is( "Damaged" ) or self:Is( "LostControl" ) then -- I think this code is not requirement anymore after release 2.5.
if DistanceFromHomeBase < 5000 then -- if self:Is( "Fuel" ) or self:Is( "Damaged" ) or self:Is( "LostControl" ) then
self:E( self.Controllable:GetName() .. " is too far from home base, RTB!" ) -- if DistanceFromHomeBase < 5000 then
self:Home( "Destroy" ) -- self:E( self.Controllable:GetName() .. " is near the home base, RTB!" )
end -- self:Home( "Destroy" )
end -- end
-- end
if not self:Is( "Fuel" ) and not self:Is( "Home" ) then if not self:Is( "Fuel" ) and not self:Is( "Home" ) then
@ -481,9 +482,12 @@ function AI_A2A:onafterStatus()
end end
-- Check if planes went RTB and are out of control. -- Check if planes went RTB and are out of control.
-- We only check if planes are out of control, when they are in duty.
if self.Controllable:HasTask() == false then if self.Controllable:HasTask() == false then
if not self:Is( "Started" ) and if not self:Is( "Started" ) and
not self:Is( "Stopped" ) and not self:Is( "Stopped" ) and
not self:Is( "Fuel" ) and
not self:Is( "Damaged" ) and
not self:Is( "Home" ) then not self:Is( "Home" ) then
if self.IdleCount >= 2 then if self.IdleCount >= 2 then
if Damage ~= InitialLife then if Damage ~= InitialLife then
@ -502,7 +506,9 @@ function AI_A2A:onafterStatus()
if RTB == true then if RTB == true then
self:__RTB( 0.5 ) self:__RTB( 0.5 )
else end
if not self:Is("Home") then
self:__Status( 10 ) self:__Status( 10 )
end end