mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
SPOT
LaseCoordinate Alarm state ships zonRadius in task fire at point.
This commit is contained in:
parent
2a485ef85a
commit
c88f7bede5
@ -126,6 +126,39 @@ do
|
|||||||
-- @param Wrapper.Positionable#POSITIONABLE Target
|
-- @param Wrapper.Positionable#POSITIONABLE Target
|
||||||
-- @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.
|
||||||
|
|
||||||
|
self:AddTransition( "Off", "LaseOnCoordinate", "On" )
|
||||||
|
|
||||||
|
--- LaseOnCoordinate Handler OnBefore for SPOT.
|
||||||
|
-- @function [parent=#SPOT] OnBeforeLaseOnCoordinate
|
||||||
|
-- @param #SPOT self
|
||||||
|
-- @param #string From
|
||||||
|
-- @param #string Event
|
||||||
|
-- @param #string To
|
||||||
|
-- @return #boolean
|
||||||
|
|
||||||
|
--- LaseOnCoordinate Handler OnAfter for SPOT.
|
||||||
|
-- @function [parent=#SPOT] OnAfterLaseOnCoordinate
|
||||||
|
-- @param #SPOT self
|
||||||
|
-- @param #string From
|
||||||
|
-- @param #string Event
|
||||||
|
-- @param #string To
|
||||||
|
|
||||||
|
--- LaseOnCoordinate Trigger for SPOT.
|
||||||
|
-- @function [parent=#SPOT] LaseOnCoordinate
|
||||||
|
-- @param #SPOT self
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate The coordinate to lase.
|
||||||
|
-- @param #number LaserCode Laser code.
|
||||||
|
-- @param #number Duration Duration of lasing in seconds.
|
||||||
|
|
||||||
|
--- LaseOn Asynchronous Trigger for SPOT
|
||||||
|
-- @function [parent=#SPOT] __LaseOn
|
||||||
|
-- @param #SPOT self
|
||||||
|
-- @param #number Delay
|
||||||
|
-- @param Wrapper.Positionable#POSITIONABLE Target
|
||||||
|
-- @param #number LaserCode Laser code.
|
||||||
|
-- @param #number Duration Duration of lasing in seconds.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self:AddTransition( "On", "Lasing", "On" )
|
self:AddTransition( "On", "Lasing", "On" )
|
||||||
@ -194,7 +227,8 @@ do
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #SPOT self
|
--- On after LaseOn event. Activates the laser spot.
|
||||||
|
-- @param #SPOT self
|
||||||
-- @param From
|
-- @param From
|
||||||
-- @param Event
|
-- @param Event
|
||||||
-- @param To
|
-- @param To
|
||||||
@ -226,6 +260,43 @@ do
|
|||||||
|
|
||||||
self:__Lasing( -1 )
|
self:__Lasing( -1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- On after LaseOnCoordinate event. Activates the laser spot.
|
||||||
|
-- @param #SPOT self
|
||||||
|
-- @param From
|
||||||
|
-- @param Event
|
||||||
|
-- @param To
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate The coordinate at which the laser is pointing.
|
||||||
|
-- @param #number LaserCode Laser code.
|
||||||
|
-- @param #number Duration Duration of lasing in seconds.
|
||||||
|
function SPOT:onafterLaseOnCoordinate(From, Event, To, Coordinate, LaserCode, Duration)
|
||||||
|
self:F( { "LaseOnCoordinate", Coordinate, LaserCode, Duration } )
|
||||||
|
|
||||||
|
local function StopLase( self )
|
||||||
|
self:LaseOff()
|
||||||
|
end
|
||||||
|
|
||||||
|
self.Target = nil
|
||||||
|
self.TargetCoord=Coordinate
|
||||||
|
self.LaserCode = LaserCode
|
||||||
|
|
||||||
|
self.Lasing = true
|
||||||
|
|
||||||
|
local RecceDcsUnit = self.Recce:GetDCSObject()
|
||||||
|
|
||||||
|
local aimat=Coordinate
|
||||||
|
aimat.y=aimat.y+1
|
||||||
|
|
||||||
|
self.SpotIR = Spot.createInfraRed( RecceDcsUnit, { x = 0, y = 2, z = 0 }, aimat:GetVec3() )
|
||||||
|
self.SpotLaser = Spot.createLaser( RecceDcsUnit, { x = 0, y = 2, z = 0 }, aimat:GetVec3(), LaserCode )
|
||||||
|
|
||||||
|
if Duration then
|
||||||
|
self.ScheduleID = self.LaseScheduler:Schedule( self, StopLase, {self}, Duration )
|
||||||
|
end
|
||||||
|
|
||||||
|
self:__Lasing(-1)
|
||||||
|
end
|
||||||
|
|
||||||
--- @param #SPOT self
|
--- @param #SPOT self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
@ -246,10 +317,20 @@ do
|
|||||||
-- @param To
|
-- @param To
|
||||||
function SPOT:onafterLasing( From, Event, To )
|
function SPOT:onafterLasing( From, Event, To )
|
||||||
|
|
||||||
if self.Target:IsAlive() then
|
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.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.SpotLaser:setPoint( self.Target:GetPointVec3():AddY(1):GetVec3() )
|
||||||
self:__Lasing( -0.2 )
|
self:__Lasing( -0.2 )
|
||||||
|
elseif self.TargetCoord then
|
||||||
|
|
||||||
|
local aimat=self.TargetCoord --Core.Point#COORDINATE
|
||||||
|
aimat.y=aimat.y+1+math.random(-100,100)/100
|
||||||
|
aimat.x=aimat.x+math.random(-100,100)/100
|
||||||
|
|
||||||
|
self.SpotIR:setPoint(aimat:GetVec3())
|
||||||
|
self.SpotLaser:setPoint(self.TargetCoord:GetVec3())
|
||||||
|
|
||||||
|
self:__Lasing( -0.2 )
|
||||||
else
|
else
|
||||||
self:F( { "Target is not alive", self.Target:IsAlive() } )
|
self:F( { "Target is not alive", self.Target:IsAlive() } )
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1388,7 +1388,7 @@ function CONTROLLABLE:TaskFireAtPoint( Vec2, Radius, AmmoCount, WeaponType )
|
|||||||
DCSTask = { id = 'FireAtPoint',
|
DCSTask = { id = 'FireAtPoint',
|
||||||
params = {
|
params = {
|
||||||
point = Vec2,
|
point = Vec2,
|
||||||
radius = Radius,
|
zoneRadius = Radius,
|
||||||
expendQty = 100, -- dummy value
|
expendQty = 100, -- dummy value
|
||||||
expendQtyEnabled = false,
|
expendQtyEnabled = false,
|
||||||
}
|
}
|
||||||
@ -3165,7 +3165,8 @@ function CONTROLLABLE:OptionAlarmStateAuto()
|
|||||||
if self:IsGround() then
|
if self:IsGround() then
|
||||||
Controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.AUTO)
|
Controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.AUTO)
|
||||||
elseif self:IsShip() then
|
elseif self:IsShip() then
|
||||||
Controller:setOption(AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.AUTO)
|
--Controller:setOption(AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.AUTO)
|
||||||
|
Controller:setOption(9, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -3189,6 +3190,7 @@ function CONTROLLABLE:OptionAlarmStateGreen()
|
|||||||
elseif self:IsShip() then
|
elseif self:IsShip() then
|
||||||
-- AI.Option.Naval.id.ALARM_STATE does not seem to exist!
|
-- AI.Option.Naval.id.ALARM_STATE does not seem to exist!
|
||||||
--Controller:setOption( AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.GREEN )
|
--Controller:setOption( AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.GREEN )
|
||||||
|
Controller:setOption(9, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -3210,7 +3212,8 @@ function CONTROLLABLE:OptionAlarmStateRed()
|
|||||||
if self:IsGround() then
|
if self:IsGround() then
|
||||||
Controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.RED)
|
Controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.RED)
|
||||||
elseif self:IsShip() then
|
elseif self:IsShip() then
|
||||||
Controller:setOption(AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.RED)
|
--Controller:setOption(AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.RED)
|
||||||
|
Controller:setOption(9, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|||||||
@ -1184,6 +1184,24 @@ function POSITIONABLE:LaseUnit( Target, LaserCode, Duration ) --R2.1
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Start Lasing a COORDINATE.
|
||||||
|
-- @param #POSITIONABLE self
|
||||||
|
-- @param Core.Point#COORDIUNATE Coordinate The coordinate where the lase is pointing at.
|
||||||
|
-- @param #number LaserCode Laser code or random number in [1000, 9999].
|
||||||
|
-- @param #number Duration Duration of lasing in seconds.
|
||||||
|
-- @return Core.Spot#SPOT
|
||||||
|
function POSITIONABLE:LaseCoordinate(Coordinate, LaserCode, Duration)
|
||||||
|
self:F2()
|
||||||
|
|
||||||
|
LaserCode = LaserCode or math.random(1000, 9999)
|
||||||
|
|
||||||
|
self.Spot = SPOT:New(self) -- Core.Spot#SPOT
|
||||||
|
self.Spot:LaseOnCoordinate(Coordinate, LaserCode, Duration)
|
||||||
|
self.LaserCode = LaserCode
|
||||||
|
|
||||||
|
return self.Spot
|
||||||
|
end
|
||||||
|
|
||||||
--- Stop Lasing a POSITIONABLE
|
--- Stop Lasing a POSITIONABLE
|
||||||
-- @param #POSITIONABLE self
|
-- @param #POSITIONABLE self
|
||||||
-- @return #POSITIONABLE
|
-- @return #POSITIONABLE
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user