UNIT:IsPlayer() Small fix for an error that is I think produced by the swapr script

This commit is contained in:
Applevangelist 2024-06-22 11:53:52 +02:00
parent 8cdf8677c1
commit 11a05f1333

View File

@ -445,7 +445,11 @@ function UNIT:IsPlayer()
if not group then return false end if not group then return false end
-- Units of template group. -- 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. -- Get numbers.
for _,unit in pairs(units) do for _,unit in pairs(units) do
@ -1192,17 +1196,17 @@ function UNIT:GetThreatLevel()
if self:IsGround() then if self:IsGround() then
local ThreatLevels = { local ThreatLevels = {
"Unarmed", [1] = "Unarmed",
"Infantry", [2] = "Infantry",
"Old Tanks & APCs", [3] = "Old Tanks & APCs",
"Tanks & IFVs without ATGM", [4] = "Tanks & IFVs without ATGM",
"Tanks & IFV with ATGM", [5] = "Tanks & IFV with ATGM",
"Modern Tanks", [6] = "Modern Tanks",
"AAA", [7] = "AAA",
"IR Guided SAMs", [8] = "IR Guided SAMs",
"SR SAMs", [9] = "SR SAMs",
"MR SAMs", [10] = "MR SAMs",
"LR SAMs" [11] = "LR SAMs"
} }
@ -1228,17 +1232,17 @@ function UNIT:GetThreatLevel()
if self:IsAir() then if self:IsAir() then
local ThreatLevels = { local ThreatLevels = {
"Unarmed", [1] = "Unarmed",
"Tanker", [2] = "Tanker",
"AWACS", [3] = "AWACS",
"Transport Helicopter", [4] = "Transport Helicopter",
"UAV", [5] = "UAV",
"Bomber", [6] = "Bomber",
"Strategic Bomber", [7] = "Strategic Bomber",
"Attack Helicopter", [8] = "Attack Helicopter",
"Battleplane", [9] = "Battleplane",
"Multirole Fighter", [10] = "Multirole Fighter",
"Fighter" [11] = "Fighter"
} }
@ -1272,17 +1276,17 @@ function UNIT:GetThreatLevel()
--["Unarmed ships"] = {"Ships","HeavyArmoredUnits",}, --["Unarmed ships"] = {"Ships","HeavyArmoredUnits",},
local ThreatLevels = { local ThreatLevels = {
"Unarmed ship", [1] = "Unarmed ship",
"Light armed ships", [2] = "Light armed ships",
"Corvettes", [3] = "Corvettes",
"", [4] = "",
"Frigates", [5] = "Frigates",
"", [6] = "",
"Cruiser", [7] = "Cruiser",
"", [8] = "",
"Destroyer", [9] = "Destroyer",
"", [10] = "",
"Aircraft Carrier" [11] = "Aircraft Carrier"
} }