Merge branch 'develop' into FF/OpsDev

This commit is contained in:
Frank
2024-06-27 21:31:24 +02:00
10 changed files with 310 additions and 131 deletions

View File

@@ -445,7 +445,11 @@ function UNIT:IsPlayer()
if not group then return false end
-- Units of template group.
local units=group:GetTemplate().units
local template = group:GetTemplate()
if (template == nil) or (template.units == nil ) then return false end
local units=template.units
-- Get numbers.
for _,unit in pairs(units) do
@@ -789,11 +793,13 @@ end
--- Get the number of ammunition and in particular the number of shells, rockets, bombs and missiles a unit currently has.
-- @param #UNIT self
-- @return #number Total amount of ammo the unit has left. This is the sum of shells, rockets, bombs and missiles.
-- @return #number Number of shells left.
-- @return #number Number of shells left. Shells include MG ammunition, AP and HE shells, and artillery shells where applicable.
-- @return #number Number of rockets left.
-- @return #number Number of bombs left.
-- @return #number Number of missiles left.
-- @return #number Number of artillery shells left (with explosive mass, included in shells; shells can also be machine gun ammo)
-- @return #number Number of artillery shells left (with explosive mass, included in shells; HE will also be reported as artillery shells for tanks)
-- @return #number Number of tank AP shells left (for tanks, if applicable)
-- @return #number Number of tank HE shells left (for tanks, if applicable)
function UNIT:GetAmmunition()
-- Init counter.
@@ -803,6 +809,8 @@ function UNIT:GetAmmunition()
local nmissiles=0
local nbombs=0
local narti=0
local nAPshells = 0
local nHEshells = 0
local unit=self
@@ -844,6 +852,14 @@ function UNIT:GetAmmunition()
narti=narti+Nammo
end
if ammotable[w].desc.typeName and string.find(ammotable[w].desc.typeName,"_AP",1,true) then
nAPshells = nAPshells+Nammo
end
if ammotable[w].desc.typeName and string.find(ammotable[w].desc.typeName,"_HE",1,true) then
nHEshells = nHEshells+Nammo
end
elseif Category==Weapon.Category.ROCKET then
-- Add up all rockets.
@@ -880,7 +896,55 @@ function UNIT:GetAmmunition()
-- Total amount of ammunition.
nammo=nshells+nrockets+nmissiles+nbombs
return nammo, nshells, nrockets, nbombs, nmissiles, narti
return nammo, nshells, nrockets, nbombs, nmissiles, narti, nAPshells, nHEshells
end
--- Checks if a tank still has AP shells.
-- @param #UNIT self
-- @return #boolean HasAPShells
function UNIT:HasAPShells()
local _,_,_,_,_,_,shells = self:GetAmmunition()
if shells > 0 then return true else return false end
end
--- Get number of AP shells from a tank.
-- @param #UNIT self
-- @return #number Number of AP shells
function UNIT:GetAPShells()
local _,_,_,_,_,_,shells = self:GetAmmunition()
return shells or 0
end
--- Get number of HE shells from a tank.
-- @param #UNIT self
-- @return #number Number of HE shells
function UNIT:GetHEShells()
local _,_,_,_,_,_,_,shells = self:GetAmmunition()
return shells or 0
end
--- Checks if a tank still has HE shells.
-- @param #UNIT self
-- @return #boolean HasHEShells
function UNIT:HasHEShells()
local _,_,_,_,_,_,_,shells = self:GetAmmunition()
if shells > 0 then return true else return false end
end
--- Checks if an artillery unit still has artillery shells.
-- @param #UNIT self
-- @return #boolean HasArtiShells
function UNIT:HasArtiShells()
local _,_,_,_,_,shells = self:GetAmmunition()
if shells > 0 then return true else return false end
end
--- Get number of artillery shells from an artillery unit.
-- @param #UNIT self
-- @return #number Number of artillery shells
function UNIT:GetArtiShells()
local _,_,_,_,_,shells = self:GetAmmunition()
return shells or 0
end
--- Returns the unit sensors.
@@ -1192,17 +1256,17 @@ function UNIT:GetThreatLevel()
if self:IsGround() then
local ThreatLevels = {
"Unarmed",
"Infantry",
"Old Tanks & APCs",
"Tanks & IFVs without ATGM",
"Tanks & IFV with ATGM",
"Modern Tanks",
"AAA",
"IR Guided SAMs",
"SR SAMs",
"MR SAMs",
"LR SAMs"
[1] = "Unarmed",
[2] = "Infantry",
[3] = "Old Tanks & APCs",
[4] = "Tanks & IFVs without ATGM",
[5] = "Tanks & IFV with ATGM",
[6] = "Modern Tanks",
[7] = "AAA",
[8] = "IR Guided SAMs",
[9] = "SR SAMs",
[10] = "MR SAMs",
[11] = "LR SAMs"
}
@@ -1228,17 +1292,17 @@ function UNIT:GetThreatLevel()
if self:IsAir() then
local ThreatLevels = {
"Unarmed",
"Tanker",
"AWACS",
"Transport Helicopter",
"UAV",
"Bomber",
"Strategic Bomber",
"Attack Helicopter",
"Battleplane",
"Multirole Fighter",
"Fighter"
[1] = "Unarmed",
[2] = "Tanker",
[3] = "AWACS",
[4] = "Transport Helicopter",
[5] = "UAV",
[6] = "Bomber",
[7] = "Strategic Bomber",
[8] = "Attack Helicopter",
[9] = "Battleplane",
[10] = "Multirole Fighter",
[11] = "Fighter"
}
@@ -1272,17 +1336,17 @@ function UNIT:GetThreatLevel()
--["Unarmed ships"] = {"Ships","HeavyArmoredUnits",},
local ThreatLevels = {
"Unarmed ship",
"Light armed ships",
"Corvettes",
"",
"Frigates",
"",
"Cruiser",
"",
"Destroyer",
"",
"Aircraft Carrier"
[1] = "Unarmed ship",
[2] = "Light armed ships",
[3] = "Corvettes",
[4] = "",
[5] = "Frigates",
[6] = "",
[7] = "Cruiser",
[8] = "",
[9] = "Destroyer",
[10] = "",
[11] = "Aircraft Carrier"
}