mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Merge remote-tracking branch 'origin/master' into branch
This commit is contained in:
commit
3bb5d3709b
@ -3152,7 +3152,7 @@ function GROUP:IsSAM()
|
|||||||
local units = self:GetUnits()
|
local units = self:GetUnits()
|
||||||
for _,_unit in pairs(units or {}) do
|
for _,_unit in pairs(units or {}) do
|
||||||
local unit = _unit -- Wrapper.Unit#UNIT
|
local unit = _unit -- Wrapper.Unit#UNIT
|
||||||
if unit:HasSEAD() and unit:IsGround() and (not unit:HasAttribute("Mobile AAA")) then
|
if unit:IsSAM() then
|
||||||
issam = true
|
issam = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -3162,18 +3162,16 @@ end
|
|||||||
|
|
||||||
--- [GROUND] Determine if a GROUP has a AAA unit, i.e. has no radar or optical tracker but the AAA = true or the "Mobile AAA" = true attribute.
|
--- [GROUND] Determine if a GROUP has a AAA unit, i.e. has no radar or optical tracker but the AAA = true or the "Mobile AAA" = true attribute.
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @return #boolean IsSAM True if AAA, else false
|
-- @return #boolean IsAAA True if AAA, else false
|
||||||
function GROUP:IsAAA()
|
function GROUP:IsAAA()
|
||||||
local issam = false
|
local isAAA = false
|
||||||
local units = self:GetUnits()
|
local units = self:GetUnits()
|
||||||
for _,_unit in pairs(units or {}) do
|
for _,_unit in pairs(units or {}) do
|
||||||
local unit = _unit -- Wrapper.Unit#UNIT
|
local unit = _unit -- Wrapper.Unit#UNIT
|
||||||
local desc = unit:GetDesc() or {}
|
if unit:IsAAA() then
|
||||||
local attr = desc.attributes or {}
|
isAAA = true
|
||||||
if unit:HasSEAD() then return false end
|
break
|
||||||
if attr["AAA"] or attr["SAM related"] then
|
|
||||||
issam = true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return issam
|
return isAAA
|
||||||
end
|
end
|
||||||
|
|||||||
@ -470,7 +470,9 @@ function UNIT:IsPlayer()
|
|||||||
-- Get group.
|
-- Get group.
|
||||||
local group = self:GetGroup()
|
local group = self:GetGroup()
|
||||||
|
|
||||||
if not group then return false end
|
if not group then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
-- Units of template group.
|
-- Units of template group.
|
||||||
local template = group:GetTemplate()
|
local template = group:GetTemplate()
|
||||||
@ -478,7 +480,11 @@ function UNIT:IsPlayer()
|
|||||||
if (template == nil) or (template.units == nil) then
|
if (template == nil) or (template.units == nil) then
|
||||||
local DCSObject = self:GetDCSObject()
|
local DCSObject = self:GetDCSObject()
|
||||||
if DCSObject then
|
if DCSObject then
|
||||||
if DCSObject:getPlayerName() ~= nil then return true else return false end
|
if DCSObject:getPlayerName() ~= nil then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -939,7 +945,11 @@ end
|
|||||||
-- @return #boolean HasAPShells
|
-- @return #boolean HasAPShells
|
||||||
function UNIT:HasAPShells()
|
function UNIT:HasAPShells()
|
||||||
local _, _, _, _, _, _, shells = self:GetAmmunition()
|
local _, _, _, _, _, _, shells = self:GetAmmunition()
|
||||||
if shells > 0 then return true else return false end
|
if shells > 0 then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get number of AP shells from a tank.
|
--- Get number of AP shells from a tank.
|
||||||
@ -963,7 +973,11 @@ end
|
|||||||
-- @return #boolean HasHEShells
|
-- @return #boolean HasHEShells
|
||||||
function UNIT:HasHEShells()
|
function UNIT:HasHEShells()
|
||||||
local _, _, _, _, _, _, _, shells = self:GetAmmunition()
|
local _, _, _, _, _, _, _, shells = self:GetAmmunition()
|
||||||
if shells > 0 then return true else return false end
|
if shells > 0 then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Checks if an artillery unit still has artillery shells.
|
--- Checks if an artillery unit still has artillery shells.
|
||||||
@ -971,7 +985,11 @@ end
|
|||||||
-- @return #boolean HasArtiShells
|
-- @return #boolean HasArtiShells
|
||||||
function UNIT:HasArtiShells()
|
function UNIT:HasArtiShells()
|
||||||
local _, _, _, _, _, shells = self:GetAmmunition()
|
local _, _, _, _, _, shells = self:GetAmmunition()
|
||||||
if shells > 0 then return true else return false end
|
if shells > 0 then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get number of artillery shells from an artillery unit.
|
--- Get number of artillery shells from an artillery unit.
|
||||||
@ -1304,21 +1322,30 @@ function UNIT:GetThreatLevel()
|
|||||||
[11] = "LR SAMs"
|
[11] = "LR SAMs"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if Attributes["LR SAM"] then
|
||||||
if Attributes["LR SAM"] then ThreatLevel = 10
|
ThreatLevel = 10
|
||||||
elseif Attributes["MR SAM"] then ThreatLevel = 9
|
elseif Attributes["MR SAM"] then
|
||||||
|
ThreatLevel = 9
|
||||||
elseif Attributes["SR SAM"] and
|
elseif Attributes["SR SAM"] and
|
||||||
not Attributes["IR Guided SAM"] then ThreatLevel = 8
|
not Attributes["IR Guided SAM"] then
|
||||||
|
ThreatLevel = 8
|
||||||
elseif (Attributes["SR SAM"] or Attributes["MANPADS"]) and
|
elseif (Attributes["SR SAM"] or Attributes["MANPADS"]) and
|
||||||
Attributes["IR Guided SAM"] then ThreatLevel = 7
|
Attributes["IR Guided SAM"] then
|
||||||
elseif Attributes["AAA"] then ThreatLevel = 6
|
ThreatLevel = 7
|
||||||
elseif Attributes["Modern Tanks"] then ThreatLevel = 5
|
elseif Attributes["AAA"] then
|
||||||
|
ThreatLevel = 6
|
||||||
|
elseif Attributes["Modern Tanks"] then
|
||||||
|
ThreatLevel = 5
|
||||||
elseif (Attributes["Tanks"] or Attributes["IFV"]) and
|
elseif (Attributes["Tanks"] or Attributes["IFV"]) and
|
||||||
Attributes["ATGM"] then ThreatLevel = 4
|
Attributes["ATGM"] then
|
||||||
|
ThreatLevel = 4
|
||||||
elseif (Attributes["Tanks"] or Attributes["IFV"]) and
|
elseif (Attributes["Tanks"] or Attributes["IFV"]) and
|
||||||
not Attributes["ATGM"] then ThreatLevel = 3
|
not Attributes["ATGM"] then
|
||||||
elseif Attributes["Old Tanks"] or Attributes["APC"] or Attributes["Artillery"] then ThreatLevel = 2
|
ThreatLevel = 3
|
||||||
elseif Attributes["Infantry"] or Attributes["EWR"] then ThreatLevel = 1
|
elseif Attributes["Old Tanks"] or Attributes["APC"] or Attributes["Artillery"] then
|
||||||
|
ThreatLevel = 2
|
||||||
|
elseif Attributes["Infantry"] or Attributes["EWR"] then
|
||||||
|
ThreatLevel = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
ThreatText = ThreatLevels[ThreatLevel + 1]
|
ThreatText = ThreatLevels[ThreatLevel + 1]
|
||||||
@ -1340,19 +1367,30 @@ function UNIT:GetThreatLevel()
|
|||||||
[11] = "Fighter"
|
[11] = "Fighter"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if Attributes["Fighters"] then
|
||||||
if Attributes["Fighters"] then ThreatLevel = 10
|
ThreatLevel = 10
|
||||||
elseif Attributes["Multirole fighters"] then ThreatLevel = 9
|
elseif Attributes["Multirole fighters"] then
|
||||||
elseif Attributes["Interceptors"] then ThreatLevel = 9
|
ThreatLevel = 9
|
||||||
elseif Attributes["Battleplanes"] then ThreatLevel = 8
|
elseif Attributes["Interceptors"] then
|
||||||
elseif Attributes["Battle airplanes"] then ThreatLevel = 8
|
ThreatLevel = 9
|
||||||
elseif Attributes["Attack helicopters"] then ThreatLevel = 7
|
elseif Attributes["Battleplanes"] then
|
||||||
elseif Attributes["Strategic bombers"] then ThreatLevel = 6
|
ThreatLevel = 8
|
||||||
elseif Attributes["Bombers"] then ThreatLevel = 5
|
elseif Attributes["Battle airplanes"] then
|
||||||
elseif Attributes["UAVs"] then ThreatLevel = 4
|
ThreatLevel = 8
|
||||||
elseif Attributes["Transport helicopters"] then ThreatLevel = 3
|
elseif Attributes["Attack helicopters"] then
|
||||||
elseif Attributes["AWACS"] then ThreatLevel = 2
|
ThreatLevel = 7
|
||||||
elseif Attributes["Tankers"] then ThreatLevel = 1
|
elseif Attributes["Strategic bombers"] then
|
||||||
|
ThreatLevel = 6
|
||||||
|
elseif Attributes["Bombers"] then
|
||||||
|
ThreatLevel = 5
|
||||||
|
elseif Attributes["UAVs"] then
|
||||||
|
ThreatLevel = 4
|
||||||
|
elseif Attributes["Transport helicopters"] then
|
||||||
|
ThreatLevel = 3
|
||||||
|
elseif Attributes["AWACS"] then
|
||||||
|
ThreatLevel = 2
|
||||||
|
elseif Attributes["Tankers"] then
|
||||||
|
ThreatLevel = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
ThreatText = ThreatLevels[ThreatLevel + 1]
|
ThreatText = ThreatLevels[ThreatLevel + 1]
|
||||||
@ -1384,13 +1422,18 @@ function UNIT:GetThreatLevel()
|
|||||||
[11] = "Aircraft Carrier"
|
[11] = "Aircraft Carrier"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if Attributes["Aircraft Carriers"] then
|
||||||
if Attributes["Aircraft Carriers"] then ThreatLevel = 10
|
ThreatLevel = 10
|
||||||
elseif Attributes["Destroyers"] then ThreatLevel = 8
|
elseif Attributes["Destroyers"] then
|
||||||
elseif Attributes["Cruisers"] then ThreatLevel = 6
|
ThreatLevel = 8
|
||||||
elseif Attributes["Frigates"] then ThreatLevel = 4
|
elseif Attributes["Cruisers"] then
|
||||||
elseif Attributes["Corvettes"] then ThreatLevel = 2
|
ThreatLevel = 6
|
||||||
elseif Attributes["Light armed ships"] then ThreatLevel = 1
|
elseif Attributes["Frigates"] then
|
||||||
|
ThreatLevel = 4
|
||||||
|
elseif Attributes["Corvettes"] then
|
||||||
|
ThreatLevel = 2
|
||||||
|
elseif Attributes["Light armed ships"] then
|
||||||
|
ThreatLevel = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
ThreatText = ThreatLevels[ThreatLevel + 1]
|
ThreatText = ThreatLevels[ThreatLevel + 1]
|
||||||
@ -1548,7 +1591,8 @@ function UNIT:InAir(NoHeloCheck)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- Event Handling
|
do
|
||||||
|
-- Event Handling
|
||||||
|
|
||||||
--- Subscribe to a DCS Event.
|
--- Subscribe to a DCS Event.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
@ -1588,13 +1632,15 @@ do -- Event Handling
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- Detection
|
do
|
||||||
|
-- Detection
|
||||||
|
|
||||||
--- Returns if a unit is detecting the TargetUnit.
|
--- Returns if a unit is detecting the TargetUnit.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @param #UNIT TargetUnit
|
-- @param #UNIT TargetUnit
|
||||||
-- @return #boolean true If the TargetUnit is detected by the unit, otherwise false.
|
-- @return #boolean true If the TargetUnit is detected by the unit, otherwise false.
|
||||||
function UNIT:IsDetected( TargetUnit ) --R2.1
|
function UNIT:IsDetected(TargetUnit)
|
||||||
|
--R2.1
|
||||||
|
|
||||||
local TargetIsDetected, TargetIsVisible, TargetLastTime, TargetKnowType, TargetKnowDistance, TargetLastPos, TargetLastVelocity = self:IsTargetDetected(TargetUnit:GetDCSObject())
|
local TargetIsDetected, TargetIsVisible, TargetLastTime, TargetKnowType, TargetKnowDistance, TargetLastPos, TargetLastVelocity = self:IsTargetDetected(TargetUnit:GetDCSObject())
|
||||||
|
|
||||||
@ -1605,7 +1651,8 @@ do -- Detection
|
|||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @param #UNIT TargetUnit
|
-- @param #UNIT TargetUnit
|
||||||
-- @return #boolean true If the TargetUnit has LOS with the unit, otherwise false.
|
-- @return #boolean true If the TargetUnit has LOS with the unit, otherwise false.
|
||||||
function UNIT:IsLOS( TargetUnit ) --R2.1
|
function UNIT:IsLOS(TargetUnit)
|
||||||
|
--R2.1
|
||||||
|
|
||||||
local IsLOS = self:GetPointVec3():IsLOS(TargetUnit:GetPointVec3())
|
local IsLOS = self:GetPointVec3():IsLOS(TargetUnit:GetPointVec3())
|
||||||
|
|
||||||
@ -1797,3 +1844,69 @@ function UNIT:GetSTN()
|
|||||||
end
|
end
|
||||||
return STN, VCL, VCN, FGL
|
return STN, VCL, VCN, FGL
|
||||||
end
|
end
|
||||||
|
|
||||||
|
do
|
||||||
|
-- AI methods
|
||||||
|
|
||||||
|
--- Turns the AI On or Off for the UNIT.
|
||||||
|
-- @param #UNIT self
|
||||||
|
-- @param #boolean AIOnOff The value true turns the AI On, the value false turns the AI Off.
|
||||||
|
-- @return #UNIT The UNIT.
|
||||||
|
function UNIT:SetAIOnOff(AIOnOff)
|
||||||
|
|
||||||
|
local DCSUnit = self:GetDCSObject() -- DCS#Group
|
||||||
|
|
||||||
|
if DCSUnit then
|
||||||
|
local DCSController = DCSUnit:getController() -- DCS#Controller
|
||||||
|
if DCSController then
|
||||||
|
DCSController:setOnOff(AIOnOff)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Turns the AI On for the UNIT.
|
||||||
|
-- @param #UNIT self
|
||||||
|
-- @return #UNIT The UNIT.
|
||||||
|
function UNIT:SetAIOn()
|
||||||
|
|
||||||
|
return self:SetAIOnOff(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Turns the AI Off for the UNIT.
|
||||||
|
-- @param #UNIT self
|
||||||
|
-- @return #UNIT The UNIT.
|
||||||
|
function UNIT:SetAIOff()
|
||||||
|
|
||||||
|
return self:SetAIOnOff(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [GROUND] Determine if a UNIT is a SAM unit, i.e. has radar or optical tracker and is no mobile AAA.
|
||||||
|
-- @param #UNIT self
|
||||||
|
-- @return #boolean IsSAM True if SAM, else false
|
||||||
|
function UNIT:IsSAM()
|
||||||
|
if self:HasSEAD() and self:IsGround() and (not self:HasAttribute("Mobile AAA")) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [GROUND] Determine if a UNIT is a AAA unit, i.e. has no radar or optical tracker but the AAA = true or the "Mobile AAA" = true attribute.
|
||||||
|
-- @param #UNIT self
|
||||||
|
-- @return #boolean IsAAA True if AAA, else false
|
||||||
|
function UNIT:IsAAA()
|
||||||
|
local unit = self -- Wrapper.Unit#UNIT
|
||||||
|
local desc = unit:GetDesc() or {}
|
||||||
|
local attr = desc.attributes or {}
|
||||||
|
if unit:HasSEAD() then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
if attr["AAA"] or attr["SAM related"] then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user