mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-23 02:08:17 +00:00
AUTOLASE - added nil check for CanLase()
This commit is contained in:
@@ -674,25 +674,27 @@ end
|
|||||||
function AUTOLASE:CanLase(Recce,Unit)
|
function AUTOLASE:CanLase(Recce,Unit)
|
||||||
local canlase = false
|
local canlase = false
|
||||||
-- cooldown?
|
-- cooldown?
|
||||||
local name = Recce:GetName()
|
if Recce and Recce:IsAlive() == true then
|
||||||
local cooldown = self.RecceUnits[name].cooldown and self.forcecooldown
|
local name = Recce:GetName()
|
||||||
if cooldown then
|
local cooldown = self.RecceUnits[name].cooldown and self.forcecooldown
|
||||||
local Tdiff = timer.getAbsTime() - self.RecceUnits[name].timestamp
|
if cooldown then
|
||||||
if Tdiff < self.cooldowntime then
|
local Tdiff = timer.getAbsTime() - self.RecceUnits[name].timestamp
|
||||||
return false
|
if Tdiff < self.cooldowntime then
|
||||||
else
|
return false
|
||||||
self.RecceUnits[name].cooldown = false
|
else
|
||||||
|
self.RecceUnits[name].cooldown = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- calculate LOS
|
||||||
|
local reccecoord = Recce:GetCoordinate()
|
||||||
|
local unitcoord = Unit:GetCoordinate()
|
||||||
|
local islos = reccecoord:IsLOS(unitcoord,2.5)
|
||||||
|
-- calculate distance
|
||||||
|
local distance = math.floor(reccecoord:Get3DDistance(unitcoord))
|
||||||
|
local lasedistance = self:GetLosFromUnit(Recce)
|
||||||
|
if distance <= lasedistance and islos then
|
||||||
|
canlase = true
|
||||||
end
|
end
|
||||||
end
|
|
||||||
-- calculate LOS
|
|
||||||
local reccecoord = Recce:GetCoordinate()
|
|
||||||
local unitcoord = Unit:GetCoordinate()
|
|
||||||
local islos = reccecoord:IsLOS(unitcoord,2.5)
|
|
||||||
-- calculate distance
|
|
||||||
local distance = math.floor(reccecoord:Get3DDistance(unitcoord))
|
|
||||||
local lasedistance = self:GetLosFromUnit(Recce)
|
|
||||||
if distance <= lasedistance and islos then
|
|
||||||
canlase = true
|
|
||||||
end
|
end
|
||||||
return canlase
|
return canlase
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user