diff --git a/Moose Development/Moose/Functional/Fox2.lua b/Moose Development/Moose/Functional/Fox2.lua index 202d2e854..093288f71 100644 --- a/Moose Development/Moose/Functional/Fox2.lua +++ b/Moose Development/Moose/Functional/Fox2.lua @@ -322,7 +322,7 @@ function FOX2:OnEventShot(EventData) self:E(FOX2.lid..string.format("EVENT SHOT: Target name = %s", tostring(_targetName))) -- Track missiles of type AAM=1, SAM=2 or OTHER=6 - local _track = weaponcategory==1 and missilecategory and (missilecategory==1 or missilecategory==2 or missilecategory==6) + local _track = weaponcategory==1 and missilecategory and (missilecategory==1 or missilecategory==2 or missilecategory==6) -- Get shooter. local shooterUnit = EventData.IniUnit @@ -355,7 +355,12 @@ function FOX2:OnEventShot(EventData) if _targetUnit and player.launchalert and player.coalition~=shooterCoalition then -- Inform players. - local text=string.format("Missile launch detected! Distance %.1f NM, bearing %03d°.", UTILS.MetersToNM(distance), bearing) + local text=string.format("Missile launch detected! Distance %.1f NM, bearing %03d°.", UTILS.MetersToNM(distance), bearing) + + if _targetUnit and self:_GetPlayerFromUnitname(_targetUnit:GetName()) then + text=string.format("Incoming missile launch detected! Distance %.1f NM, bearing %03d°.", UTILS.MetersToNM(distance), bearing) + end + MESSAGE:New(text, 5, "ALERT"):ToClient(player.client) if player.marklaunch then @@ -369,6 +374,9 @@ function FOX2:OnEventShot(EventData) -- Init missile position. local _lastBombPos = {x=0,y=0,z=0} + -- Missile coordinate. + local missileCoord = nil --Core.Point#COORDINATE + -- Target unit of the missile. local target=nil --Wrapper.Unit#UNIT @@ -392,7 +400,7 @@ function FOX2:OnEventShot(EventData) _lastBombPos = {x=_bombPos.x, y=_bombPos.y, z=_bombPos.z} -- Missile coordinate. - local missileCoord=COORDINATE:NewFromVec3(_lastBombPos) + missileCoord=COORDINATE:NewFromVec3(_lastBombPos) -- Missile velocity in m/s. local missileVelocity=UTILS.VecNorm(_ordnance:getVelocity()) @@ -419,8 +427,8 @@ function FOX2:OnEventShot(EventData) -- Distance. local dist=missileCoord:Get3DDistance(playerCoord) - -- Update mindist if necessary. - if mindist==nil or dist