mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
SHORAD - Updates for missile without set target intel
This commit is contained in:
parent
f394bd45c7
commit
31a8c4b0b9
@ -18,7 +18,7 @@
|
|||||||
-- @module Functional.Shorad
|
-- @module Functional.Shorad
|
||||||
-- @image Functional.Shorad.jpg
|
-- @image Functional.Shorad.jpg
|
||||||
--
|
--
|
||||||
-- Date: July 2021
|
-- Date: Nov 2021
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
--- **SHORAD** class, extends Core.Base#BASE
|
--- **SHORAD** class, extends Core.Base#BASE
|
||||||
@ -132,6 +132,7 @@ do
|
|||||||
["Kh29"] = "Kh29",
|
["Kh29"] = "Kh29",
|
||||||
["Kh31"] = "Kh31",
|
["Kh31"] = "Kh31",
|
||||||
["Kh66"] = "Kh66",
|
["Kh66"] = "Kh66",
|
||||||
|
--["BGM_109"] = "BGM_109",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Instantiates a new SHORAD object
|
--- Instantiates a new SHORAD object
|
||||||
@ -163,7 +164,7 @@ do
|
|||||||
self.DefenseLowProb = 70 -- probability to detect a missile shot, low margin
|
self.DefenseLowProb = 70 -- probability to detect a missile shot, low margin
|
||||||
self.DefenseHighProb = 90 -- probability to detect a missile shot, high margin
|
self.DefenseHighProb = 90 -- probability to detect a missile shot, high margin
|
||||||
self.UseEmOnOff = UseEmOnOff or false -- Decide if we are using Emission on/off (default) or AlarmState red/green
|
self.UseEmOnOff = UseEmOnOff or false -- Decide if we are using Emission on/off (default) or AlarmState red/green
|
||||||
self:I("*** SHORAD - Started Version 0.2.8")
|
self:I("*** SHORAD - Started Version 0.2.9")
|
||||||
-- Set the string id for output to DCS.log file.
|
-- Set the string id for output to DCS.log file.
|
||||||
self.lid=string.format("SHORAD %s | ", self.name)
|
self.lid=string.format("SHORAD %s | ", self.name)
|
||||||
self:_InitState()
|
self:_InitState()
|
||||||
@ -311,7 +312,7 @@ do
|
|||||||
local hit = false
|
local hit = false
|
||||||
if self.DefendHarms then
|
if self.DefendHarms then
|
||||||
for _,_name in pairs (SHORAD.Harms) do
|
for _,_name in pairs (SHORAD.Harms) do
|
||||||
if string.find(WeaponName,_name,1) then hit = true end
|
if string.find(WeaponName,_name,1,true) then hit = true end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return hit
|
return hit
|
||||||
@ -327,7 +328,7 @@ do
|
|||||||
local hit = false
|
local hit = false
|
||||||
if self.DefendMavs then
|
if self.DefendMavs then
|
||||||
for _,_name in pairs (SHORAD.Mavs) do
|
for _,_name in pairs (SHORAD.Mavs) do
|
||||||
if string.find(WeaponName,_name,1) then hit = true end
|
if string.find(WeaponName,_name,1,true) then hit = true end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return hit
|
return hit
|
||||||
@ -368,7 +369,7 @@ do
|
|||||||
local returnname = false
|
local returnname = false
|
||||||
for _,_groups in pairs (shoradset) do
|
for _,_groups in pairs (shoradset) do
|
||||||
local groupname = _groups:GetName()
|
local groupname = _groups:GetName()
|
||||||
if string.find(groupname, tgtgrp, 1) then
|
if string.find(groupname, tgtgrp, 1, true) then
|
||||||
returnname = true
|
returnname = true
|
||||||
--_groups:RelocateGroundRandomInRadius(7,100,false,false) -- be a bit evasive
|
--_groups:RelocateGroundRandomInRadius(7,100,false,false) -- be a bit evasive
|
||||||
end
|
end
|
||||||
@ -389,7 +390,7 @@ do
|
|||||||
local returnname = false
|
local returnname = false
|
||||||
for _,_groups in pairs (shoradset) do
|
for _,_groups in pairs (shoradset) do
|
||||||
local groupname = _groups:GetName()
|
local groupname = _groups:GetName()
|
||||||
if string.find(groupname, tgtgrp, 1) then
|
if string.find(groupname, tgtgrp, 1, true) then
|
||||||
returnname = true
|
returnname = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -507,11 +508,35 @@ do
|
|||||||
local targetdata = EventData.Weapon:getTarget() -- Identify target
|
local targetdata = EventData.Weapon:getTarget() -- Identify target
|
||||||
local targetcat = targetdata:getCategory() -- Identify category
|
local targetcat = targetdata:getCategory() -- Identify category
|
||||||
self:T(string.format("Target Category (3=STATIC, 1=UNIT)= %s",tostring(targetcat)))
|
self:T(string.format("Target Category (3=STATIC, 1=UNIT)= %s",tostring(targetcat)))
|
||||||
|
self:T({targetdata})
|
||||||
local targetunit = nil
|
local targetunit = nil
|
||||||
if targetcat == Object.Category.UNIT then -- UNIT
|
if targetcat == Object.Category.UNIT then -- UNIT
|
||||||
targetunit = UNIT:Find(targetdata)
|
targetunit = UNIT:Find(targetdata)
|
||||||
elseif targetcat == Object.Category.STATIC then -- STATIC
|
elseif targetcat == Object.Category.STATIC then -- STATIC
|
||||||
targetunit = STATIC:Find(targetdata)
|
--self:T("Static Target Data")
|
||||||
|
--self:T({targetdata:isExist()})
|
||||||
|
--self:T({targetdata:getPoint()})
|
||||||
|
local tgtcoord = COORDINATE:NewFromVec3(targetdata:getPoint())
|
||||||
|
--tgtcoord:MarkToAll("Missile Target",true)
|
||||||
|
|
||||||
|
local tgtgrp1 = self.Samset:FindNearestGroupFromPointVec2(tgtcoord)
|
||||||
|
local tgtcoord1 = tgtgrp1:GetCoordinate()
|
||||||
|
--tgtcoord1:MarkToAll("Close target SAM",true)
|
||||||
|
|
||||||
|
local tgtgrp2 = self.Groupset:FindNearestGroupFromPointVec2(tgtcoord)
|
||||||
|
local tgtcoord2 = tgtgrp2:GetCoordinate()
|
||||||
|
--tgtcoord2:MarkToAll("Close target SHORAD",true)
|
||||||
|
|
||||||
|
local dist1 = tgtcoord:Get2DDistance(tgtcoord1)
|
||||||
|
local dist2 = tgtcoord:Get2DDistance(tgtcoord2)
|
||||||
|
|
||||||
|
if dist1 < dist2 then
|
||||||
|
targetunit = tgtgrp1
|
||||||
|
targetcat = Object.Category.UNIT
|
||||||
|
else
|
||||||
|
targetunit = tgtgrp2
|
||||||
|
targetcat = Object.Category.UNIT
|
||||||
|
end
|
||||||
end
|
end
|
||||||
--local targetunitname = Unit.getName(targetdata) -- Unit name
|
--local targetunitname = Unit.getName(targetdata) -- Unit name
|
||||||
if targetunit and targetunit:IsAlive() then
|
if targetunit and targetunit:IsAlive() then
|
||||||
@ -520,7 +545,11 @@ do
|
|||||||
local targetgroup = nil
|
local targetgroup = nil
|
||||||
local targetgroupname = "none"
|
local targetgroupname = "none"
|
||||||
if targetcat == Object.Category.UNIT then
|
if targetcat == Object.Category.UNIT then
|
||||||
targetgroup = targetunit:GetGroup()
|
if targetunit.ClassName == "UNIT" then
|
||||||
|
targetgroup = targetunit:GetGroup()
|
||||||
|
elseif targetunit.ClassName == "GROUP" then
|
||||||
|
targetgroup = targetunit
|
||||||
|
end
|
||||||
targetgroupname = targetgroup:GetName() -- group name
|
targetgroupname = targetgroup:GetName() -- group name
|
||||||
elseif targetcat == Object.Category.STATIC then
|
elseif targetcat == Object.Category.STATIC then
|
||||||
targetgroup = targetunit
|
targetgroup = targetunit
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user