diff --git a/Moose Development/Moose/Core/Spot.lua b/Moose Development/Moose/Core/Spot.lua index dbc3ea683..6395cd7b4 100644 --- a/Moose Development/Moose/Core/Spot.lua +++ b/Moose Development/Moose/Core/Spot.lua @@ -126,6 +126,39 @@ do -- @param Wrapper.Positionable#POSITIONABLE Target -- @param #number LaserCode Laser code. -- @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" ) @@ -194,7 +227,8 @@ do return self end - --- @param #SPOT self + --- On after LaseOn event. Activates the laser spot. + -- @param #SPOT self -- @param From -- @param Event -- @param To @@ -226,6 +260,43 @@ do self:__Lasing( -1 ) 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 Core.Event#EVENTDATA EventData @@ -246,10 +317,20 @@ do -- @param 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.SpotLaser:setPoint( self.Target:GetPointVec3():AddY(1):GetVec3() ) 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 self:F( { "Target is not alive", self.Target:IsAlive() } ) end diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 7cfb56abb..a1302776d 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -1388,7 +1388,7 @@ function CONTROLLABLE:TaskFireAtPoint( Vec2, Radius, AmmoCount, WeaponType ) DCSTask = { id = 'FireAtPoint', params = { point = Vec2, - radius = Radius, + zoneRadius = Radius, expendQty = 100, -- dummy value expendQtyEnabled = false, } @@ -3165,7 +3165,8 @@ function CONTROLLABLE:OptionAlarmStateAuto() if self:IsGround() then Controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.AUTO) 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 return self @@ -3189,6 +3190,7 @@ function CONTROLLABLE:OptionAlarmStateGreen() elseif self:IsShip() then -- 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(9, 1) end return self @@ -3210,7 +3212,8 @@ function CONTROLLABLE:OptionAlarmStateRed() if self:IsGround() then Controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.RED) 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 return self diff --git a/Moose Development/Moose/Wrapper/Positionable.lua b/Moose Development/Moose/Wrapper/Positionable.lua index 443192ed8..7f5bdd17f 100644 --- a/Moose Development/Moose/Wrapper/Positionable.lua +++ b/Moose Development/Moose/Wrapper/Positionable.lua @@ -1184,6 +1184,24 @@ function POSITIONABLE:LaseUnit( Target, LaserCode, Duration ) --R2.1 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 -- @param #POSITIONABLE self -- @return #POSITIONABLE