From dbf95924eb49d665ef90a3d0553ae64c740c26d6 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Thu, 20 Apr 2017 21:59:09 +0200 Subject: [PATCH] Updated logic... --- Moose Development/Moose/AI/AI_Designate.lua | 33 +++++++++++++++++---- Moose Development/Moose/Core/Spot.lua | 8 +++-- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Moose Development/Moose/AI/AI_Designate.lua b/Moose Development/Moose/AI/AI_Designate.lua index e1aa370f9..35ed1639a 100644 --- a/Moose Development/Moose/AI/AI_Designate.lua +++ b/Moose Development/Moose/AI/AI_Designate.lua @@ -119,7 +119,7 @@ do -- AI_DESIGNATE -- @param #AI_DESIGNATE self -- @param #number Delay - self:AddTransition( "*", "LaseOn", "*" ) + self:AddTransition( "*", "LaseOn", "Lasing" ) --- LaseOn Handler OnBefore for AI_DESIGNATE -- @function [parent=#AI_DESIGNATE ] OnBeforeLaseOn @@ -145,9 +145,10 @@ do -- AI_DESIGNATE -- @param #AI_DESIGNATE self -- @param #number Delay + self:AddTransition( "Lasing", "Lasing", "Lasing" ) - self:AddTransition( "*", "LaseOff", "*" ) + self:AddTransition( "*", "LaseOff", "Designate" ) --- LaseOff Handler OnBefore for AI_DESIGNATE -- @function [parent=#AI_DESIGNATE ] OnBeforeLaseOff @@ -413,26 +414,40 @@ do -- AI_DESIGNATE -- @return #AI_DESIGNATE function AI_DESIGNATE:onafterLaseOn( From, Event, To, AttackGroup, Index, Duration ) + self:__Lasing( -5, AttackGroup, Index, Duration ) + + end + + + --- + -- @param #AI_DESIGNATE self + -- @return #AI_DESIGNATE + function AI_DESIGNATE:onafterLasing( From, Event, To, AttackGroup, Index, Duration ) + local TargetSetUnit = self.Detection:GetDetectedSet( Index ) + local Targets = false + TargetSetUnit:ForEachUnit( --- @param Wrapper.Unit#UNIT SmokeUnit function( SmokeUnit ) self:E("In procedure") --if math.random( 1, ( 100 * TargetSetUnit:Count() ) / 100 ) <= 100 then if SmokeUnit:IsAlive() then - local NearestRecceGroup = self.RecceSet:FindNearestGroupFromPointVec2(SmokeUnit:GetPointVec2()) + local NearestRecceGroup = self.RecceSet:FindNearestGroupFromPointVec2( SmokeUnit:GetPointVec2() ) if NearestRecceGroup then for UnitID, UnitData in pairs( NearestRecceGroup:GetUnits() or {} ) do local RecceUnit = UnitData -- Wrapper.Unit#UNIT + Targets = true if RecceUnit:IsLasing() == false then self.Spots[Index] = self.Spots[Index] or {} local Spots = self.Spots[Index] local LaserCode = self.LaserCodes[math.random(1, #self.LaserCodes)] local Spot = RecceUnit:LaseUnit( SmokeUnit, LaserCode, Duration ) - Spots[#Spots+1] = Spot + Spots[RecceUnit] = Spot RecceUnit:MessageToGroup( "Lasing " .. SmokeUnit:GetTypeName() .. " for " .. Duration .. " seconds. Laser Code: " .. Spot.LaserCode, 15, AttackGroup ) break + else end end end @@ -440,10 +455,16 @@ do -- AI_DESIGNATE --end end ) - + + if Targets == true then + self:__Lasing( -30, AttackGroup, Index, Duration ) + else + self:__LaseOff( -0.2, AttackGroup, Index ) + end + self:SetDesignateMenu() + end - --- -- @param #AI_DESIGNATE self diff --git a/Moose Development/Moose/Core/Spot.lua b/Moose Development/Moose/Core/Spot.lua index fff6c5fdd..870a1f3ee 100644 --- a/Moose Development/Moose/Core/Spot.lua +++ b/Moose Development/Moose/Core/Spot.lua @@ -96,8 +96,12 @@ do -- @param To function SPOT:onafterLasing( From, Event, To ) - self:__Lasing( -0.2 ) - self.Spot:setPoint( self.Target:GetPointVec3():AddY(1):GetVec3() ) + if self.Target:IsAlive() then + self.Spot:setPoint( self.Target:GetPointVec3():AddY(1):GetVec3() ) + self:__Lasing( -0.2 ) + else + self:__LaseOff( 0.2 ) + end end