Min Fuel Fixes

AI_A2A and AI_Patrol:
Changed average fuel for controllable to new min fuel function. Hopefully provides better RTB behavior.

CONTROLLABLE:
Added GetFuelMin and GetFuelAve functions to ensure polymorphic behavior.

UNIT:
Added GetFuelMin and GetFuelAve functions for completeness and potential polymorphism.
This commit is contained in:
funkyfranky 2018-06-18 23:13:21 +02:00
parent 99963c28e9
commit 19197bf234
4 changed files with 42 additions and 4 deletions

View File

@ -452,7 +452,7 @@ function AI_A2A:onafterStatus()
if not self:Is( "Fuel" ) and not self:Is( "Home" ) then
local Fuel = self.Controllable:GetFuel()
local Fuel = self.Controllable:GetFuelMin()
self:F({Fuel=Fuel})
if Fuel < self.PatrolFuelThresholdPercentage then
if self.TankerName then

View File

@ -824,7 +824,7 @@ function AI_PATROL_ZONE:onafterStatus()
local RTB = false
local Fuel = self.Controllable:GetUnit(1):GetFuel()
local Fuel = self.Controllable:GetFuelMin()
if Fuel < self.PatrolFuelThresholdPercentage then
self:E( self.Controllable:GetName() .. " is out of fuel:" .. Fuel .. ", RTB!" )
local OldAIControllable = self.Controllable

View File

@ -259,6 +259,26 @@ function CONTROLLABLE:GetLife0()
return nil
end
--- Returns relative minimum amount of fuel (from 0.0 to 1.0) a unit or group has in its internal tanks.
-- This method returns nil to ensure polymorphic behaviour! This method needs to be overridden by GROUP or UNIT.
-- @param #CONTROLLABLE self
-- @return #nil The CONTROLLABLE is not existing or alive.
function CONTROLLABLE:GetFuelMin()
self:F( self.ControllableName )
return nil
end
--- Returns relative average amount of fuel (from 0.0 to 1.0) a unit or group has in its internal tanks.
-- This method returns nil to ensure polymorphic behaviour! This method needs to be overridden by GROUP or UNIT.
-- @param #CONTROLLABLE self
-- @return #nil The CONTROLLABLE is not existing or alive.
function CONTROLLABLE:GetFuelAve()
self:F( self.ControllableName )
return nil
end
--- Returns relative amount of fuel (from 0.0 to 1.0) the unit has in its internal tanks.
-- This method returns nil to ensure polymorphic behaviour! This method needs to be overridden by GROUP or UNIT.
-- @param #CONTROLLABLE self
@ -270,8 +290,6 @@ function CONTROLLABLE:GetFuel()
end
-- Tasks
--- Clear all tasks from the controllable.

View File

@ -571,6 +571,26 @@ function UNIT:GetFuel()
return nil
end
--- Returns relative amount of fuel (from 0.0 to 1.0) the UNIT has in its internal tanks. If there are additional fuel tanks the value may be greater than 1.0.
-- @param #UNIT self
-- @return #number The relative amount of fuel (from 0.0 to 1.0).
-- @return #nil The DCS Unit is not existing or alive.
function UNIT:GetFuelMin()
self:F( self.UnitName )
self:GetFuel()
end
--- Returns relative amount of fuel (from 0.0 to 1.0) the UNIT has in its internal tanks. If there are additional fuel tanks the value may be greater than 1.0.
-- @param #UNIT self
-- @return #number The relative amount of fuel (from 0.0 to 1.0).
-- @return #nil The DCS Unit is not existing or alive.
function UNIT:GetFuelAve()
self:F( self.UnitName )
self:GetFuel()
end
--- Returns a list of one @{Wrapper.Unit}.
-- @param #UNIT self
-- @return #list<Wrapper.Unit#UNIT> A list of one @{Wrapper.Unit}.