mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-19 22:17:13 +00:00
Fox2
This commit is contained in:
@@ -355,7 +355,12 @@ function FOX2:OnEventShot(EventData)
|
|||||||
if _targetUnit and player.launchalert and player.coalition~=shooterCoalition then
|
if _targetUnit and player.launchalert and player.coalition~=shooterCoalition then
|
||||||
|
|
||||||
-- Inform players.
|
-- 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)
|
MESSAGE:New(text, 5, "ALERT"):ToClient(player.client)
|
||||||
|
|
||||||
if player.marklaunch then
|
if player.marklaunch then
|
||||||
@@ -369,6 +374,9 @@ function FOX2:OnEventShot(EventData)
|
|||||||
-- Init missile position.
|
-- Init missile position.
|
||||||
local _lastBombPos = {x=0,y=0,z=0}
|
local _lastBombPos = {x=0,y=0,z=0}
|
||||||
|
|
||||||
|
-- Missile coordinate.
|
||||||
|
local missileCoord = nil --Core.Point#COORDINATE
|
||||||
|
|
||||||
-- Target unit of the missile.
|
-- Target unit of the missile.
|
||||||
local target=nil --Wrapper.Unit#UNIT
|
local target=nil --Wrapper.Unit#UNIT
|
||||||
|
|
||||||
@@ -392,7 +400,7 @@ function FOX2:OnEventShot(EventData)
|
|||||||
_lastBombPos = {x=_bombPos.x, y=_bombPos.y, z=_bombPos.z}
|
_lastBombPos = {x=_bombPos.x, y=_bombPos.y, z=_bombPos.z}
|
||||||
|
|
||||||
-- Missile coordinate.
|
-- Missile coordinate.
|
||||||
local missileCoord=COORDINATE:NewFromVec3(_lastBombPos)
|
missileCoord=COORDINATE:NewFromVec3(_lastBombPos)
|
||||||
|
|
||||||
-- Missile velocity in m/s.
|
-- Missile velocity in m/s.
|
||||||
local missileVelocity=UTILS.VecNorm(_ordnance:getVelocity())
|
local missileVelocity=UTILS.VecNorm(_ordnance:getVelocity())
|
||||||
@@ -419,8 +427,8 @@ function FOX2:OnEventShot(EventData)
|
|||||||
-- Distance.
|
-- Distance.
|
||||||
local dist=missileCoord:Get3DDistance(playerCoord)
|
local dist=missileCoord:Get3DDistance(playerCoord)
|
||||||
|
|
||||||
-- Update mindist if necessary.
|
-- Update mindist if necessary. Only include players in a radius of 50 NM from the
|
||||||
if mindist==nil or dist<mindist then
|
if (mindist==nil or dist<mindist) and dist<=UTILS.NMToMeters(50) then
|
||||||
mindist=dist
|
mindist=dist
|
||||||
target=player.unit
|
target=player.unit
|
||||||
end
|
end
|
||||||
@@ -437,7 +445,7 @@ function FOX2:OnEventShot(EventData)
|
|||||||
local bearing=targetCoord:HeadingTo(missileCoord)
|
local bearing=targetCoord:HeadingTo(missileCoord)
|
||||||
local eta=distance/missileVelocity
|
local eta=distance/missileVelocity
|
||||||
|
|
||||||
self:T2(self.lid..string.format("Distance = %.1f m, v=%.1f m/s, bearing=%03d°, eta=%.1f sec", distance, missileVelocity, bearing, eta))
|
self:T2(self.lid..string.format("Distance = %.1f m, v=%.1f m/s, bearing=%03d°, eta=%.1f sec", distance, missileVelocity, bearing, eta))
|
||||||
|
|
||||||
if distance<100 then
|
if distance<100 then
|
||||||
|
|
||||||
@@ -490,11 +498,16 @@ function FOX2:OnEventShot(EventData)
|
|||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
|
||||||
if target then
|
if target then
|
||||||
|
|
||||||
|
-- Get human player.
|
||||||
local player=self:_GetPlayerFromUnitname(target:GetName())
|
local player=self:_GetPlayerFromUnitname(target:GetName())
|
||||||
if player then
|
|
||||||
|
-- Check for player and distance < 10 km.
|
||||||
|
if player and missileCoord and player.unit:GetCoordinate():Get3DDistance(missileCoord)<10*1000 then
|
||||||
local text=string.format("Missile defeated. Well done, %s!", player.name)
|
local text=string.format("Missile defeated. Well done, %s!", player.name)
|
||||||
MESSAGE:New(text, 10):ToClient(player.client)
|
MESSAGE:New(text, 10):ToClient(player.client)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--Terminate the timer.
|
--Terminate the timer.
|
||||||
|
|||||||
Reference in New Issue
Block a user