Fix a rare occasion

This commit is contained in:
Applevangelist 2021-12-17 14:14:51 +01:00
parent d1d43c38cd
commit 5bae790dd8

View File

@ -312,19 +312,22 @@ function SEAD:onafterCalculateHitZone(From,Event,To,SEADWeapon,pos0,height,SEADG
targetzone:DrawZone(coalition.side.BLUE,{0,0,1},0.2,nil,nil,3,true) targetzone:DrawZone(coalition.side.BLUE,{0,0,1},0.2,nil,nil,3,true)
end end
local seadset = SET_GROUP:New():FilterPrefixes(self.SEADGroupPrefixes):FilterOnce() local seadset = SET_GROUP:New():FilterPrefixes(self.SEADGroupPrefixes):FilterZones({targetzone}):FilterOnce()
local tgtcoord = targetzone:GetRandomPointVec2() local tgtcoord = targetzone:GetRandomPointVec2()
local tgtgrp = seadset:FindNearestGroupFromPointVec2(tgtcoord) --if tgtcoord and tgtcoord.ClassName == "COORDINATE" then
local _targetgroup = nil --local tgtgrp = seadset:FindNearestGroupFromPointVec2(tgtcoord)
local _targetgroupname = "none" local tgtgrp = seadset:GetRandom()
local _targetskill = "Random" local _targetgroup = nil
if tgtgrp and tgtgrp:IsAlive() then local _targetgroupname = "none"
_targetgroup = tgtgrp local _targetskill = "Random"
_targetgroupname = tgtgrp:GetName() -- group name if tgtgrp and tgtgrp:IsAlive() then
_targetskill = tgtgrp:GetUnit(1):GetSkill() _targetgroup = tgtgrp
self:T("*** Found Target = ".. _targetgroupname) _targetgroupname = tgtgrp:GetName() -- group name
self:ManageEvasion(_targetskill,_targetgroup,pos0,"AGM_88",SEADGroup, 20) _targetskill = tgtgrp:GetUnit(1):GetSkill()
end self:T("*** Found Target = ".. _targetgroupname)
self:ManageEvasion(_targetskill,_targetgroup,pos0,"AGM_88",SEADGroup, 20)
end
--end
end end
end end
end end