mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
#Spot
This commit is contained in:
@@ -229,7 +229,8 @@ do
|
|||||||
-- @param #number LaserCode Laser code.
|
-- @param #number LaserCode Laser code.
|
||||||
-- @param #number Duration Duration of lasing in seconds.
|
-- @param #number Duration Duration of lasing in seconds.
|
||||||
function SPOT:onafterLaseOn( From, Event, To, Target, LaserCode, Duration )
|
function SPOT:onafterLaseOn( From, Event, To, Target, LaserCode, Duration )
|
||||||
self:F( { "LaseOn", Target, LaserCode, Duration } )
|
self:T({From, Event, To})
|
||||||
|
self:T2( { "LaseOn", Target, LaserCode, Duration } )
|
||||||
|
|
||||||
local function StopLase( self )
|
local function StopLase( self )
|
||||||
self:LaseOff()
|
self:LaseOff()
|
||||||
@@ -271,7 +272,7 @@ do
|
|||||||
-- @param #number LaserCode Laser code.
|
-- @param #number LaserCode Laser code.
|
||||||
-- @param #number Duration Duration of lasing in seconds.
|
-- @param #number Duration Duration of lasing in seconds.
|
||||||
function SPOT:onafterLaseOnCoordinate(From, Event, To, Coordinate, LaserCode, Duration)
|
function SPOT:onafterLaseOnCoordinate(From, Event, To, Coordinate, LaserCode, Duration)
|
||||||
self:F( { "LaseOnCoordinate", Coordinate, LaserCode, Duration } )
|
self:T2( { "LaseOnCoordinate", Coordinate, LaserCode, Duration } )
|
||||||
|
|
||||||
local function StopLase( self )
|
local function StopLase( self )
|
||||||
self:LaseOff()
|
self:LaseOff()
|
||||||
@@ -300,7 +301,7 @@ do
|
|||||||
-- @param #SPOT self
|
-- @param #SPOT self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function SPOT:OnEventDead(EventData)
|
function SPOT:OnEventDead(EventData)
|
||||||
self:F( { Dead = EventData.IniDCSUnitName, Target = self.Target } )
|
self:T2( { Dead = EventData.IniDCSUnitName, Target = self.Target } )
|
||||||
if self.Target then
|
if self.Target then
|
||||||
if EventData.IniDCSUnitName == self.TargetName then
|
if EventData.IniDCSUnitName == self.TargetName then
|
||||||
self:F( {"Target dead ", self.TargetName } )
|
self:F( {"Target dead ", self.TargetName } )
|
||||||
@@ -323,25 +324,28 @@ do
|
|||||||
-- @param Event
|
-- @param Event
|
||||||
-- @param To
|
-- @param To
|
||||||
function SPOT:onafterLasing( From, Event, To )
|
function SPOT:onafterLasing( From, Event, To )
|
||||||
|
self:T({From, Event, To})
|
||||||
if self.Target and self.Target:IsAlive() then
|
|
||||||
|
|
||||||
self.SpotIR:setPoint( self.Target:GetPointVec3():AddY(1):AddY(math.random(-100,100)/100):AddX(math.random(-100,100)/100):GetVec3() )
|
|
||||||
self.SpotLaser:setPoint( self.Target:GetPointVec3():AddY(1):GetVec3() )
|
|
||||||
|
|
||||||
self:__Lasing( -0.3 )
|
|
||||||
elseif self.TargetCoord then
|
|
||||||
|
|
||||||
-- Wiggle the IR spot a bit.
|
if self.Lasing then
|
||||||
local irvec3={x=self.TargetCoord.x+math.random(-100,100)/100, y=self.TargetCoord.y+math.random(-100,100)/100, z=self.TargetCoord.z} --#DCS.Vec3
|
if self.Target and self.Target:IsAlive() then
|
||||||
local lsvec3={x=self.TargetCoord.x, y=self.TargetCoord.y, z=self.TargetCoord.z} --#DCS.Vec3
|
|
||||||
|
self.SpotIR:setPoint( self.Target:GetPointVec3():AddY(1):AddY(math.random(-100,100)/100):AddX(math.random(-100,100)/100):GetVec3() )
|
||||||
|
self.SpotLaser:setPoint( self.Target:GetPointVec3():AddY(1):GetVec3() )
|
||||||
|
|
||||||
|
self:__Lasing(0.2)
|
||||||
|
elseif self.TargetCoord then
|
||||||
|
|
||||||
self.SpotIR:setPoint(irvec3)
|
-- Wiggle the IR spot a bit.
|
||||||
self.SpotLaser:setPoint(lsvec3)
|
local irvec3={x=self.TargetCoord.x+math.random(-100,100)/100, y=self.TargetCoord.y+math.random(-100,100)/100, z=self.TargetCoord.z} --#DCS.Vec3
|
||||||
|
local lsvec3={x=self.TargetCoord.x, y=self.TargetCoord.y, z=self.TargetCoord.z} --#DCS.Vec3
|
||||||
self:__Lasing(-0.3)
|
|
||||||
else
|
self.SpotIR:setPoint(irvec3)
|
||||||
self:F( { "Target is not alive", self.Target:IsAlive() } )
|
self.SpotLaser:setPoint(lsvec3)
|
||||||
|
|
||||||
|
self:__Lasing(0.2)
|
||||||
|
else
|
||||||
|
self:F( { "Target is not alive", self.Target:IsAlive() } )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -353,8 +357,9 @@ do
|
|||||||
-- @param To
|
-- @param To
|
||||||
-- @return #SPOT
|
-- @return #SPOT
|
||||||
function SPOT:onafterLaseOff( From, Event, To )
|
function SPOT:onafterLaseOff( From, Event, To )
|
||||||
|
self:t({From, Event, To})
|
||||||
self:F( {"Stopped lasing for ", self.Target and self.Target:GetName() or "coord", SpotIR = self.SportIR, SpotLaser = self.SpotLaser } )
|
|
||||||
|
self:T2( {"Stopped lasing for ", self.Target and self.Target:GetName() or "coord", SpotIR = self.SportIR, SpotLaser = self.SpotLaser } )
|
||||||
|
|
||||||
self.Lasing = false
|
self.Lasing = false
|
||||||
|
|
||||||
@@ -369,11 +374,7 @@ do
|
|||||||
end
|
end
|
||||||
self.ScheduleID = nil
|
self.ScheduleID = nil
|
||||||
|
|
||||||
if self.Target and self.Target:IsAlive() then
|
self.Target = nil
|
||||||
self:I("Target still alive.")
|
|
||||||
else
|
|
||||||
self.Target = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user