From b7d37c42af672b9a2a371908993266982c56a368 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Thu, 11 May 2017 11:47:30 +0200 Subject: [PATCH 1/2] Working Version! --- Moose Development/Moose/AI/AI_Formation.lua | 494 ++++++++--- docs/Documentation/AI_Follow.html | 934 +++++++++++++++++++- docs/Documentation/AI_Patrol.html | 3 + docs/Documentation/Cargo.html | 1 - docs/Documentation/Detection.html | 1 - docs/Documentation/Fsm.html | 3 +- docs/Documentation/Movement.html | 4 + docs/Documentation/Spawn.html | 32 +- docs/Documentation/SpawnStatic.html | 1 - docs/Documentation/Task_Cargo.html | 2 +- 10 files changed, 1348 insertions(+), 127 deletions(-) diff --git a/Moose Development/Moose/AI/AI_Formation.lua b/Moose Development/Moose/AI/AI_Formation.lua index 7440eeaf9..d3a18880a 100644 --- a/Moose Development/Moose/AI/AI_Formation.lua +++ b/Moose Development/Moose/AI/AI_Formation.lua @@ -67,7 +67,15 @@ -- -- The following menus are created within the RADIO MENU of an active unit hosted by a player: -- --- * @{Follow#AI_FORMATION.SetFormation}(): Set a Vec3 position for a GroupName within the GroupSet following. +-- * @{AI_Formation#AI_FORMATION.FormationRandom}(): Form a randomized formation (can cause crashed of planes :-)). +-- * @{AI_Formation#AI_FORMATION.FormationLeftLine}(): Form a left line formation. +-- * @{AI_Formation#AI_FORMATION.FormationRightLine}(): Form a right line formation. +-- * @{AI_Formation#AI_FORMATION.FormationRightWing}(): Form a right wing formation. +-- * @{AI_Formation#AI_FORMATION.FormationLeftWing}(): Form a left wing formation. +-- * @{AI_Formation#AI_FORMATION.FormationCenterLine}(): Form a center line formation. +-- * @{AI_Formation#AI_FORMATION.FormationCenterWing}(): Form a center wing formation. +-- * @{AI_Formation#AI_FORMATION.FormationCenterBoxed}(): Form a center boxed formation. +-- -- -- @usage -- -- Declare a new FollowPlanes object as follows: @@ -110,7 +118,7 @@ AI_FORMATION = { --- AI_FORMATION class constructor for an AI group -- @param #AI_FORMATION self -- @param Unit#UNIT FollowUnit The UNIT leading the FolllowGroupSet. --- @param Set#SET_GROUP FollowGroupSet The group AI escorting the FollowUnit. +-- @param Core.Set#SET_GROUP FollowGroupSet The group AI escorting the FollowUnit. -- @param #string FollowName Name of the escort. -- @return #AI_FORMATION self function AI_FORMATION:New( FollowUnit, FollowGroupSet, FollowName, FollowBriefing ) @@ -126,23 +134,151 @@ function AI_FORMATION:New( FollowUnit, FollowGroupSet, FollowName, FollowBriefin self:AddTransition( "None", "Start", "Following" ) - self:AddTransition( "*", "Follow", "Following" ) + self:AddTransition( "*", "FormationLeftLine", "*" ) - FollowGroupSet:ForEachGroup( - --- @param Group#GROUP FollowGroup - function( FollowGroup, FollowName, FollowUnit ) - local Vec3 = { x = math.random( -20, -150 ), y = math.random( -50, 50 ), z = math.random( -800, 800 ) } - FollowGroup:SetState( self, "Vec3", Vec3 ) - FollowGroup:OptionROTPassiveDefense() - FollowGroup:OptionROEReturnFire() - --FollowGroup:MessageToClient( FollowGroup:GetCategoryName() .. " '" .. FollowName .. "' (" .. FollowGroup:GetCallsign() .. ") reporting! " .. - -- "We're following your flight. ", - -- 60, FollowUnit - --) - end, - FollowName, self.FollowUnit - ) + --- FormationLeftLine Handler OnBefore for AI_FORMATION + -- @function [parent=#AI_FORMATION] OnBeforeFormationLeftLine + -- @param #AI_FORMATION self + -- @param Core.Set#SET_GROUP FollowGroupSet The group AI escorting the FollowUnit. + -- @param #string From + -- @param #string Event + -- @param #string To + -- @param #number XSpace The space on the X-axis in meters between each group. + -- @param #nubmer YSpace The start position on the Y-axis in meters for each group. + -- @param #number ZSpace The start position on the Z-axis in meters for each group. + -- @return #boolean + + --- FormationLeftLine Handler OnAfter for AI_FORMATION + -- @function [parent=#AI_FORMATION] OnAfterFormationLeftLine + -- @param #AI_FORMATION self + -- @param Core.Set#SET_GROUP FollowGroupSet The group AI escorting the FollowUnit. + -- @param #string From + -- @param #string Event + -- @param #string To + -- @param #number XSpace The space on the X-axis in meters between each group. + -- @param #nubmer YSpace The start position on the Y-axis in meters for each group. + -- @param #number ZSpace The start position on the Z-axis in meters for each group. + + --- FormationLeftLine Trigger for AI_FORMATION + -- @function [parent=#AI_FORMATION] FormationLeftLine + -- @param #AI_FORMATION self + + --- FormationLeftLine Asynchronous Trigger for AI_FORMATION + -- @function [parent=#AI_FORMATION] __FormationLeftLine + -- @param #AI_FORMATION self + -- @param #number Delay + + + self:AddTransition( "*", "FormationRightLine", "*" ) + + --- FormationRightLine Handler OnBefore for AI_FORMATION + -- @function [parent=#AI_FORMATION] OnBeforeFormationRightLine + -- @param #AI_FORMATION self + -- @param Core.Set#SET_GROUP FollowGroupSet The group AI escorting the FollowUnit. + -- @param #string From + -- @param #string Event + -- @param #string To + -- @param #number XSpace The space on the X-axis in meters between each group. + -- @param #nubmer YSpace The start position on the Y-axis in meters for each group. + -- @param #number ZSpace The start position on the Z-axis in meters for each group. + -- @return #boolean + + --- FormationRightLine Handler OnAfter for AI_FORMATION + -- @function [parent=#AI_FORMATION] OnAfterFormationRightLine + -- @param #AI_FORMATION self + -- @param Core.Set#SET_GROUP FollowGroupSet The group AI escorting the FollowUnit. + -- @param #string From + -- @param #string Event + -- @param #string To + -- @param #number XSpace The space on the X-axis in meters between each group. + -- @param #nubmer YSpace The start position on the Y-axis in meters for each group. + -- @param #number ZSpace The start position on the Z-axis in meters for each group. + + --- FormationRightLine Trigger for AI_FORMATION + -- @function [parent=#AI_FORMATION] FormationRightLine + -- @param #AI_FORMATION self + + --- FormationRightLine Asynchronous Trigger for AI_FORMATION + -- @function [parent=#AI_FORMATION] __FormationRightLine + -- @param #AI_FORMATION self + -- @param #number Delay + + self:AddTransition( "*", "FormationLeftWing", "*" ) + + --- FormationLeftWing Handler OnBefore for AI_FORMATION + -- @function [parent=#AI_FORMATION] OnBeforeFormationLeftWing + -- @param #AI_FORMATION self + -- @param Core.Set#SET_GROUP FollowGroupSet The group AI escorting the FollowUnit. + -- @param #string From + -- @param #string Event + -- @param #string To + -- @param #number XSpace The space on the X-axis in meters between each group. + -- @param #nubmer YSpace The start position on the Y-axis in meters for each group. + -- @param #number ZSpace The start position on the Z-axis in meters for each group. + -- @return #boolean + + --- FormationLeftWing Handler OnAfter for AI_FORMATION + -- @function [parent=#AI_FORMATION] OnAfterFormationLeftWing + -- @param #AI_FORMATION self + -- @param Core.Set#SET_GROUP FollowGroupSet The group AI escorting the FollowUnit. + -- @param #string From + -- @param #string Event + -- @param #string To + -- @param #number XSpace The space on the X-axis in meters between each group. + -- @param #nubmer YSpace The start position on the Y-axis in meters for each group. + -- @param #number ZSpace The start position on the Z-axis in meters for each group. + + --- FormationLeftWing Trigger for AI_FORMATION + -- @function [parent=#AI_FORMATION] FormationLeftWing + -- @param #AI_FORMATION self + + --- FormationLeftWing Asynchronous Trigger for AI_FORMATION + -- @function [parent=#AI_FORMATION] __FormationLeftWing + -- @param #AI_FORMATION self + -- @param #number Delay + + + self:AddTransition( "*", "FormationRightWing", "*" ) + + --- FormationRightWing Handler OnBefore for AI_FORMATION + -- @function [parent=#AI_FORMATION] OnBeforeFormationRightWing + -- @param #AI_FORMATION self + -- @param Core.Set#SET_GROUP FollowGroupSet The group AI escorting the FollowUnit. + -- @param #string From + -- @param #string Event + -- @param #string To + -- @param #number XSpace The space on the X-axis in meters between each group. + -- @param #nubmer YSpace The start position on the Y-axis in meters for each group. + -- @param #number ZSpace The start position on the Z-axis in meters for each group. + -- @return #boolean + + --- FormationRightWing Handler OnAfter for AI_FORMATION + -- @function [parent=#AI_FORMATION] OnAfterFormationRightWing + -- @param #AI_FORMATION self + -- @param Core.Set#SET_GROUP FollowGroupSet The group AI escorting the FollowUnit. + -- @param #string From + -- @param #string Event + -- @param #string To + -- @param #number XSpace The space on the X-axis in meters between each group. + -- @param #nubmer YSpace The start position on the Y-axis in meters for each group. + -- @param #number ZSpace The start position on the Z-axis in meters for each group. + + --- FormationRightWing Trigger for AI_FORMATION + -- @function [parent=#AI_FORMATION] FormationRightWing + -- @param #AI_FORMATION self + + --- FormationRightWing Asynchronous Trigger for AI_FORMATION + -- @function [parent=#AI_FORMATION] __FormationRightWing + -- @param #AI_FORMATION self + -- @param #number Delay + + + + + + self:AddTransition( "*", "Follow", "Following" ) + self:FormationLeftLine( 50, 0, 100 ) self.FollowName = FollowName self.FollowBriefing = FollowBriefing @@ -160,11 +296,150 @@ end -- This allows to visualize where the escort is flying to. -- @param #AI_FORMATION self -- @param #boolean SmokeDirection If true, then the direction vector will be smoked. +-- @return #AI_FORMATION function AI_FORMATION:TestSmokeDirectionVector( SmokeDirection ) self.SmokeDirectionVector = ( SmokeDirection == true ) and true or false return self end +--- FormationLeftLine Handler OnAfter for AI_FORMATION +-- @function [parent=#AI_FORMATION] OnAfterFormationLeftLine +-- @param #AI_FORMATION self +-- @param Core.Set#SET_GROUP FollowGroupSet The group AI escorting the FollowUnit. +-- @param #string From +-- @param #string Event +-- @param #string To +-- @param #number XSpace The space on the X-axis in meters between each group. +-- @param #nubmer YSpace The start position on the Y-axis in meters for each group. +-- @param #number ZSpace The start position on the Z-axis in meters for each group. +function AI_FORMATION:onafterFormationLeftLine( FollowGroupSet, From , Event , To, XSpace, YSpace, ZSpace ) + self:E( { FollowGroupSet, From , Event , To, XSpace, YSpace, ZSpace } ) + + FollowGroupSet:Flush() + + local FollowSet = FollowGroupSet:GetSet() + + local i = 0 + + for FollowID, FollowGroup in pairs( FollowSet ) do + + local PointVec3 = POINT_VEC3:New() + PointVec3:SetX( -XSpace ) + PointVec3:SetY( YSpace ) + PointVec3:SetZ( i * ZSpace ) + + local Vec3 = PointVec3:GetVec3() + self:E( Vec3 ) + FollowGroup:SetState( self, "Vec3", Vec3 ) + FollowGroup:OptionROTPassiveDefense() + FollowGroup:OptionROEReturnFire() + i = i + 1 + end + +end + + +--- FormationRightLine Handler OnAfter for AI_FORMATION +-- @function [parent=#AI_FORMATION] OnAfterFormationLeftLine +-- @param #AI_FORMATION self +-- @param Core.Set#SET_GROUP FollowGroupSet The group AI escorting the FollowUnit. +-- @param #string From +-- @param #string Event +-- @param #string To +-- @param #number XSpace The space on the X-axis in meters between each group. +-- @param #nubmer YSpace The start position on the Y-axis in meters for each group. +-- @param #number ZSpace The start position on the Z-axis in meters for each group. +function AI_FORMATION:onafterFormationRightLine( FollowGroupSet, From , Event , To, XSpace, YSpace, ZSpace ) + + local FollowSet = FollowGroupSet:GetSet() + + local i = 0 + + for FollowID, FollowGroup in pairs( FollowSet ) do + + local PointVec3 = POINT_VEC3:New() + PointVec3:SetX( i * XSpace ) + PointVec3:SetY( YSpace ) + PointVec3:SetZ( -ZSpace ) + + local Vec3 = PointVec3:GetVec3() + self:E( Vec3 ) + FollowGroup:SetState( self, "Vec3", Vec3 ) + FollowGroup:OptionROTPassiveDefense() + FollowGroup:OptionROEReturnFire() + i = i + 1 + end + +end + + +--- FormationLeftWing Handler OnAfter for AI_FORMATION +-- @function [parent=#AI_FORMATION] OnAfterFormationLeftWing +-- @param #AI_FORMATION self +-- @param Core.Set#SET_GROUP FollowGroupSet The group AI escorting the FollowUnit. +-- @param #string From +-- @param #string Event +-- @param #string To +-- @param #number XSpace The space on the X-axis in meters between each group. +-- @param #nubmer YSpace The start position on the Y-axis in meters for each group. +-- @param #number ZSpace The start position on the Z-axis in meters for each group. +function AI_FORMATION:onafterFormationLeftWing( FollowGroupSet, From , Event , To, XSpace, YSpace, ZSpace ) + + local FollowSet = FollowGroupSet:GetSet() + + local i = 0 + + for FollowID, FollowGroup in pairs( FollowSet ) do + + local PointVec3 = POINT_VEC3:New() + PointVec3:SetX( -i * XSpace ) + PointVec3:SetY( i * YSpace ) + PointVec3:SetZ( -ZSpace ) + + local Vec3 = PointVec3:GetVec3() + self:E( Vec3 ) + FollowGroup:SetState( self, "Vec3", Vec3 ) + FollowGroup:OptionROTPassiveDefense() + FollowGroup:OptionROEReturnFire() + i = i + 1 + end + +end + + +--- FormationRightWing Handler OnAfter for AI_FORMATION +-- @function [parent=#AI_FORMATION] OnAfterFormationLeftWing +-- @param #AI_FORMATION self +-- @param Core.Set#SET_GROUP FollowGroupSet The group AI escorting the FollowUnit. +-- @param #string From +-- @param #string Event +-- @param #string To +-- @param #number XSpace The space on the X-axis in meters between each group. +-- @param #nubmer YSpace The start position on the Y-axis in meters for each group. +-- @param #number ZSpace The start position on the Z-axis in meters for each group. +function AI_FORMATION:onafterFormationRightWing( FollowGroupSet, From , Event , To, XSpace, YSpace, ZSpace ) + + local FollowSet = FollowGroupSet:GetSet() + + local i = 0 + + for FollowID, FollowGroup in pairs( FollowSet ) do + + local PointVec3 = POINT_VEC3:New() + PointVec3:SetX( i * XSpace ) + PointVec3:SetY( i * YSpace ) + PointVec3:SetZ( -ZSpace ) + + local Vec3 = PointVec3:GetVec3() + self:E( Vec3 ) + FollowGroup:SetState( self, "Vec3", Vec3 ) + FollowGroup:OptionROTPassiveDefense() + FollowGroup:OptionROEReturnFire() + i = i + 1 + end + +end + --- @param Follow#AI_FORMATION self function AI_FORMATION:onenterFollowing( FollowGroupSet ) @@ -194,111 +469,108 @@ function AI_FORMATION:onenterFollowing( FollowGroupSet ) end FollowGroupSet:ForEachGroup( - --- @param Group#GROUP FollowGroup - -- @param Unit#UNIT ClientUnit + --- @param Wrapper.Group#GROUP FollowGroup + -- @param Wrapper.Unit#UNIT ClientUnit function( FollowGroup, ClientUnit, CT1, CV1, CT2, CV2 ) local GroupUnit = FollowGroup:GetUnit( 1 ) local FollowFormation = FollowGroup:GetState( self, "Vec3" ) - self:T( FollowFormation ) - local FollowDistance = FollowFormation.x - - self:T( {ClientUnit.UnitName, GroupUnit.UnitName } ) - - local GT1 = GroupUnit:GetState( self, "GT1" ) - - if CT1 == nil or CT1 == 0 or GT1 == nil or GT1 == 0 then - GroupUnit:SetState( self, "GV1", GroupUnit:GetPointVec3() ) - GroupUnit:SetState( self, "GT1", timer.getTime() ) - else - local CD = ( ( CV2.x - CV1.x )^2 + ( CV2.y - CV1.y )^2 + ( CV2.z - CV1.z )^2 ) ^ 0.5 - local CT = CT2 - CT1 - - local CS = ( 3600 / CT ) * ( CD / 1000 ) - - self:T2( { "Client:", CS, CD, CT, CV2, CV1, CT2, CT1 } ) - + if FollowFormation then + local FollowDistance = FollowFormation.x + local GT1 = GroupUnit:GetState( self, "GT1" ) - local GT2 = timer.getTime() - local GV1 = GroupUnit:GetState( self, "GV1" ) - local GV2 = GroupUnit:GetPointVec3() - GroupUnit:SetState( self, "GT1", GT2 ) - GroupUnit:SetState( self, "GV1", GV2 ) - - local GD = ( ( GV2.x - GV1.x )^2 + ( GV2.y - GV1.y )^2 + ( GV2.z - GV1.z )^2 ) ^ 0.5 - local GT = GT2 - GT1 - - local GS = ( 3600 / GT ) * ( GD / 1000 ) - - self:T2( { "Group:", GS, GD, GT, GV2, GV1, GT2, GT1 } ) - - -- Calculate the group direction vector - local GV = { x = GV2.x - CV2.x, y = GV2.y - CV2.y, z = GV2.z - CV2.z } - - -- Calculate GH2, GH2 with the same height as CV2. - local GH2 = { x = GV2.x, y = CV2.y, z = GV2.z } - - -- Calculate the angle of GV to the orthonormal plane - local alpha = math.atan2( GV.z, GV.x ) - - -- Now we calculate the intersecting vector between the circle around CV2 with radius FollowDistance and GH2. - -- From the GeoGebra model: CVI = (x(CV2) + FollowDistance cos(alpha), y(GH2) + FollowDistance sin(alpha), z(CV2)) - local CVI = { x = CV2.x + FollowDistance * math.cos(alpha), - y = GH2.y + FollowFormation.y, - z = CV2.z + FollowDistance * math.sin(alpha), - } - - -- Calculate the direction vector DV of the escort group. We use CVI as the base and CV2 as the direction. - local DV = { x = CV2.x - CVI.x, y = CV2.y - CVI.y, z = CV2.z - CVI.z } - - -- We now calculate the unary direction vector DVu, so that we can multiply DVu with the speed, which is expressed in meters / s. - -- We need to calculate this vector to predict the point the escort group needs to fly to according its speed. - -- The distance of the destination point should be far enough not to have the aircraft starting to swipe left to right... - local DVu = { x = DV.x / FollowDistance, y = DV.y / FollowDistance, z = DV.z / FollowDistance } - - -- Now we can calculate the group destination vector GDV. - local GDV = { x = DVu.x * CS * 8 + CVI.x, y = CVI.y, z = DVu.z * CS * 8 + CVI.z } - - local GDV_Formation = { - x = GDV.x + ( FollowFormation.x * math.cos(alpha) - FollowFormation.z * math.sin(alpha) ), - y = GDV.y, - z = GDV.z + ( FollowFormation.z * math.cos(alpha) + FollowFormation.x * math.sin(alpha) ) - } - - if self.SmokeDirectionVector == true then - trigger.action.smoke( GDV, trigger.smokeColor.Green ) - trigger.action.smoke( GDV_Formation, trigger.smokeColor.White ) + + if CT1 == nil or CT1 == 0 or GT1 == nil or GT1 == 0 then + GroupUnit:SetState( self, "GV1", GroupUnit:GetPointVec3() ) + GroupUnit:SetState( self, "GT1", timer.getTime() ) + else + local CD = ( ( CV2.x - CV1.x )^2 + ( CV2.y - CV1.y )^2 + ( CV2.z - CV1.z )^2 ) ^ 0.5 + local CT = CT2 - CT1 + + local CS = ( 3600 / CT ) * ( CD / 1000 ) + + self:T2( { "Client:", CS, CD, CT, CV2, CV1, CT2, CT1 } ) + + local GT1 = GroupUnit:GetState( self, "GT1" ) + local GT2 = timer.getTime() + local GV1 = GroupUnit:GetState( self, "GV1" ) + local GV2 = GroupUnit:GetPointVec3() + GroupUnit:SetState( self, "GT1", GT2 ) + GroupUnit:SetState( self, "GV1", GV2 ) + + local GD = ( ( GV2.x - GV1.x )^2 + ( GV2.y - GV1.y )^2 + ( GV2.z - GV1.z )^2 ) ^ 0.5 + local GT = GT2 - GT1 + + local GS = ( 3600 / GT ) * ( GD / 1000 ) + + --self:E( { "Group:", GS = GS,GD = GD, GT = GT, GV2 = GV2, GV1 = GV1, GT2 = GT2, GT1 = GT1 } ) + + -- Calculate the group direction vector + local GV = { x = GV2.x - CV2.x + FollowFormation.x, y = GV2.y - CV2.y, z = GV2.z - CV2.z + FollowFormation.z } + + -- Calculate GH2, GH2 with the same height as CV2. + local GH2 = { x = GV2.x, y = CV2.y, z = GV2.z } + + -- Calculate the angle of GV to the orthonormal plane + local alpha = math.atan2( GV.z, GV.x ) + + -- Now we calculate the intersecting vector between the circle around CV2 with radius FollowDistance and GH2. + -- From the GeoGebra model: CVI = (x(CV2) + FollowDistance cos(alpha), y(GH2) + FollowDistance sin(alpha), z(CV2)) + local CVI = { x = CV2.x + FollowDistance * math.cos(alpha), + y = GH2.y, -- + FollowFormation.y, + z = CV2.z + FollowDistance * math.sin(alpha), + } + + -- Calculate the direction vector DV of the escort group. We use CVI as the base and CV2 as the direction. + local DV = { x = CV2.x - CVI.x, y = CV2.y - CVI.y, z = CV2.z - CVI.z } + + -- We now calculate the unary direction vector DVu, so that we can multiply DVu with the speed, which is expressed in meters / s. + -- We need to calculate this vector to predict the point the escort group needs to fly to according its speed. + -- The distance of the destination point should be far enough not to have the aircraft starting to swipe left to right... + local DVu = { x = DV.x / FollowDistance, y = DV.y, z = DV.z / FollowDistance } + + -- Now we can calculate the group destination vector GDV. + local GDV = { x = DVu.x * CS * 10 + CVI.x, y = CVI.y, z = DVu.z * CS * 10 + CVI.z } + + local ADDx = FollowFormation.x * math.cos(alpha) - FollowFormation.z * math.sin(alpha) + local ADDz = FollowFormation.z * math.cos(alpha) + FollowFormation.x * math.sin(alpha) + + self:E( { ALPHA = alpha, GDVx = GDV.x, GDVz = GDV.z, ADDx = ADDx, ADDz = ADDz, FOLLOWx = FollowFormation.x, FOLLOWz = FollowFormation.z } ) + +-- local GDV_Formation = GDV + local GDV_Formation = { + x = GDV.x + ADDx, + y = GDV.y, + z = GDV.z + ADDz + } + + if self.SmokeDirectionVector == true then + trigger.action.smoke( GDV, trigger.smokeColor.Green ) + trigger.action.smoke( GDV_Formation, trigger.smokeColor.White ) + end + + -- Measure distance between client and group + local CatchUpDistance = ( ( GDV_Formation.x - GV2.x )^2 + ( GDV_Formation.y - GV2.y )^2 + ( GDV_Formation.z - GV2.z )^2 ) ^ 0.5 + + -- The calculation of the Speed would simulate that the group would take 30 seconds to overcome + -- the requested Distance). + local Time = 10 + local CatchUpSpeed = ( CatchUpDistance - ( CS * 20 ) ) / Time + + local Speed = CS + CatchUpSpeed + if Speed < 0 then + Speed = 0 + end + + -- Now route the escort to the desired point with the desired speed. + FollowGroup:RouteToVec3( GDV_Formation, Speed / 3.6 ) -- DCS models speed in Mps (Miles per second) end - - self:T3( { "CV2:", CV2 } ) - self:T3( { "CVI:", CVI } ) - self:T2( { "GDV:", GDV } ) - - -- Measure distance between client and group - local CatchUpDistance = ( ( GDV_Formation.x - GV2.x )^2 + ( GDV_Formation.y - GV2.y )^2 + ( GDV_Formation.z - GV2.z )^2 ) ^ 0.5 - - -- The calculation of the Speed would simulate that the group would take 30 seconds to overcome - -- the requested Distance). - local Time = 20 - local CatchUpSpeed = ( CatchUpDistance - ( CS * 9.5 ) ) / Time - - local Speed = CS + CatchUpSpeed - if Speed < 0 then - Speed = 0 - end - - self:T({CatchUpDistance, CatchUpSpeed}) - - self:T3( { "Client Speed, Follow Speed, Speed, FollowDistance, Time:", CS, GS, Speed, FollowDistance, Time } ) - - -- Now route the escort to the desired point with the desired speed. - FollowGroup:RouteToVec3( GDV_Formation, Speed / 3.6 ) -- DCS models speed in Mps (Miles per second) end end, ClientUnit, CT1, CV1, CT2, CV2 ) - self:__Follow( -0.5 ) + self:__Follow( -10 ) end end diff --git a/docs/Documentation/AI_Follow.html b/docs/Documentation/AI_Follow.html index 7cd88cbc5..662723ab7 100644 --- a/docs/Documentation/AI_Follow.html +++ b/docs/Documentation/AI_Follow.html @@ -197,12 +197,84 @@ AI_FORMATION.FollowUnit + + + + AI_FORMATION:FormationLeftLine() + +

FormationLeftLine Trigger for AI_FORMATION

+ + + + AI_FORMATION:FormationLeftWing() + +

FormationLeftWing Trigger for AI_FORMATION

+ + + + AI_FORMATION:FormationRightLine() + +

FormationRightLine Trigger for AI_FORMATION

+ + + + AI_FORMATION:FormationRightWing() + +

FormationRightWing Trigger for AI_FORMATION

AI_FORMATION:New(FollowUnit, FollowGroupSet, FollowName, FollowBriefing)

AI_FORMATION class constructor for an AI group

+ + + + AI_FORMATION:OnAfterFormationLeftLine(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +

FormationRightLine Handler OnAfter for AI_FORMATION

+ + + + AI_FORMATION:OnAfterFormationLeftWing(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +

FormationRightWing Handler OnAfter for AI_FORMATION

+ + + + AI_FORMATION:OnAfterFormationRightLine(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +

FormationRightLine Handler OnAfter for AI_FORMATION

+ + + + AI_FORMATION:OnAfterFormationRightWing(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +

FormationRightWing Handler OnAfter for AI_FORMATION

+ + + + AI_FORMATION:OnBeforeFormationLeftLine(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +

FormationLeftLine Handler OnBefore for AI_FORMATION

+ + + + AI_FORMATION:OnBeforeFormationLeftWing(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +

FormationLeftWing Handler OnBefore for AI_FORMATION

+ + + + AI_FORMATION:OnBeforeFormationRightLine(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +

FormationRightLine Handler OnBefore for AI_FORMATION

+ + + + AI_FORMATION:OnBeforeFormationRightWing(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +

FormationRightWing Handler OnBefore for AI_FORMATION

@@ -227,6 +299,54 @@ AI_FORMATION:TestSmokeDirectionVector(SmokeDirection)

This function is for test, it will put on the frequency of the FollowScheduler a red smoke at the direction vector calculated for the escort to fly to.

+ + + + AI_FORMATION:__FormationLeftLine(Delay) + +

FormationLeftLine Asynchronous Trigger for AI_FORMATION

+ + + + AI_FORMATION:__FormationLeftWing(Delay) + +

FormationLeftWing Asynchronous Trigger for AI_FORMATION

+ + + + AI_FORMATION:__FormationRightLine(Delay) + +

FormationRightLine Asynchronous Trigger for AI_FORMATION

+ + + + AI_FORMATION:__FormationRightWing(Delay) + +

FormationRightWing Asynchronous Trigger for AI_FORMATION

+ + + + AI_FORMATION:onafterFormationLeftLine(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + + + + + + AI_FORMATION:onafterFormationLeftWing(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + + + + + + AI_FORMATION:onafterFormationRightLine(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + + + + + + AI_FORMATION:onafterFormationRightWing(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + + @@ -311,10 +431,18 @@

The following menus are created within the RADIO MENU of an active unit hosted by a player:

+

Usage:

-- Declare a new FollowPlanes object as follows:
 
@@ -431,6 +559,58 @@ FollowPlanes = AI_FORMATION:New( FollowUnit, FollowGroup, "Desert", "Welcome to
 	
 
 
+
+
+		
+
+ + +AI_FORMATION:FormationLeftLine() + +
+
+ +

FormationLeftLine Trigger for AI_FORMATION

+ +
+
+
+
+ + +AI_FORMATION:FormationLeftWing() + +
+
+ +

FormationLeftWing Trigger for AI_FORMATION

+ +
+
+
+
+ + +AI_FORMATION:FormationRightLine() + +
+
+ +

FormationRightLine Trigger for AI_FORMATION

+ +
+
+
+
+ + +AI_FORMATION:FormationRightWing() + +
+
+ +

FormationRightWing Trigger for AI_FORMATION

+
@@ -454,7 +634,7 @@ The UNIT leading the FolllowGroupSet.

  • -

    Set#SET_GROUP FollowGroupSet : +

    Core.Set#SET_GROUP FollowGroupSet : The group AI escorting the FollowUnit.

  • @@ -475,6 +655,466 @@ Name of the escort.

    #AI_FORMATION: self

    + +
    +
    +
    + + +AI_FORMATION:OnAfterFormationLeftLine(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +
    +
    + +

    FormationRightLine Handler OnAfter for AI_FORMATION

    + +

    Parameters

    +
      +
    • + +

      Core.Set#SET_GROUP FollowGroupSet : +The group AI escorting the FollowUnit.

      + +
    • +
    • + +

      #string From :

      + +
    • +
    • + +

      #string Event :

      + +
    • +
    • + +

      #string To :

      + +
    • +
    • + +

      #number XSpace : +The space on the X-axis in meters between each group.

      + +
    • +
    • + +

      #nubmer YSpace : +The start position on the Y-axis in meters for each group.

      + +
    • +
    • + +

      #number ZSpace : +The start position on the Z-axis in meters for each group.

      + +
    • +
    +
    +
    +
    +
    + + +AI_FORMATION:OnAfterFormationLeftWing(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +
    +
    + +

    FormationRightWing Handler OnAfter for AI_FORMATION

    + +

    Parameters

    +
      +
    • + +

      Core.Set#SET_GROUP FollowGroupSet : +The group AI escorting the FollowUnit.

      + +
    • +
    • + +

      #string From :

      + +
    • +
    • + +

      #string Event :

      + +
    • +
    • + +

      #string To :

      + +
    • +
    • + +

      #number XSpace : +The space on the X-axis in meters between each group.

      + +
    • +
    • + +

      #nubmer YSpace : +The start position on the Y-axis in meters for each group.

      + +
    • +
    • + +

      #number ZSpace : +The start position on the Z-axis in meters for each group.

      + +
    • +
    +
    +
    +
    +
    + + +AI_FORMATION:OnAfterFormationRightLine(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +
    +
    + +

    FormationRightLine Handler OnAfter for AI_FORMATION

    + +

    Parameters

    +
      +
    • + +

      Core.Set#SET_GROUP FollowGroupSet : +The group AI escorting the FollowUnit.

      + +
    • +
    • + +

      #string From :

      + +
    • +
    • + +

      #string Event :

      + +
    • +
    • + +

      #string To :

      + +
    • +
    • + +

      #number XSpace : +The space on the X-axis in meters between each group.

      + +
    • +
    • + +

      #nubmer YSpace : +The start position on the Y-axis in meters for each group.

      + +
    • +
    • + +

      #number ZSpace : +The start position on the Z-axis in meters for each group.

      + +
    • +
    +
    +
    +
    +
    + + +AI_FORMATION:OnAfterFormationRightWing(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +
    +
    + +

    FormationRightWing Handler OnAfter for AI_FORMATION

    + +

    Parameters

    +
      +
    • + +

      Core.Set#SET_GROUP FollowGroupSet : +The group AI escorting the FollowUnit.

      + +
    • +
    • + +

      #string From :

      + +
    • +
    • + +

      #string Event :

      + +
    • +
    • + +

      #string To :

      + +
    • +
    • + +

      #number XSpace : +The space on the X-axis in meters between each group.

      + +
    • +
    • + +

      #nubmer YSpace : +The start position on the Y-axis in meters for each group.

      + +
    • +
    • + +

      #number ZSpace : +The start position on the Z-axis in meters for each group.

      + +
    • +
    +
    +
    +
    +
    + + +AI_FORMATION:OnBeforeFormationLeftLine(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +
    +
    + +

    FormationLeftLine Handler OnBefore for AI_FORMATION

    + +

    Parameters

    +
      +
    • + +

      Core.Set#SET_GROUP FollowGroupSet : +The group AI escorting the FollowUnit.

      + +
    • +
    • + +

      #string From :

      + +
    • +
    • + +

      #string Event :

      + +
    • +
    • + +

      #string To :

      + +
    • +
    • + +

      #number XSpace : +The space on the X-axis in meters between each group.

      + +
    • +
    • + +

      #nubmer YSpace : +The start position on the Y-axis in meters for each group.

      + +
    • +
    • + +

      #number ZSpace : +The start position on the Z-axis in meters for each group.

      + +
    • +
    +

    Return value

    + +

    #boolean:

    + + +
    +
    +
    +
    + + +AI_FORMATION:OnBeforeFormationLeftWing(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +
    +
    + +

    FormationLeftWing Handler OnBefore for AI_FORMATION

    + +

    Parameters

    +
      +
    • + +

      Core.Set#SET_GROUP FollowGroupSet : +The group AI escorting the FollowUnit.

      + +
    • +
    • + +

      #string From :

      + +
    • +
    • + +

      #string Event :

      + +
    • +
    • + +

      #string To :

      + +
    • +
    • + +

      #number XSpace : +The space on the X-axis in meters between each group.

      + +
    • +
    • + +

      #nubmer YSpace : +The start position on the Y-axis in meters for each group.

      + +
    • +
    • + +

      #number ZSpace : +The start position on the Z-axis in meters for each group.

      + +
    • +
    +

    Return value

    + +

    #boolean:

    + + +
    +
    +
    +
    + + +AI_FORMATION:OnBeforeFormationRightLine(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +
    +
    + +

    FormationRightLine Handler OnBefore for AI_FORMATION

    + +

    Parameters

    +
      +
    • + +

      Core.Set#SET_GROUP FollowGroupSet : +The group AI escorting the FollowUnit.

      + +
    • +
    • + +

      #string From :

      + +
    • +
    • + +

      #string Event :

      + +
    • +
    • + +

      #string To :

      + +
    • +
    • + +

      #number XSpace : +The space on the X-axis in meters between each group.

      + +
    • +
    • + +

      #nubmer YSpace : +The start position on the Y-axis in meters for each group.

      + +
    • +
    • + +

      #number ZSpace : +The start position on the Z-axis in meters for each group.

      + +
    • +
    +

    Return value

    + +

    #boolean:

    + + +
    +
    +
    +
    + + +AI_FORMATION:OnBeforeFormationRightWing(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +
    +
    + +

    FormationRightWing Handler OnBefore for AI_FORMATION

    + +

    Parameters

    +
      +
    • + +

      Core.Set#SET_GROUP FollowGroupSet : +The group AI escorting the FollowUnit.

      + +
    • +
    • + +

      #string From :

      + +
    • +
    • + +

      #string Event :

      + +
    • +
    • + +

      #string To :

      + +
    • +
    • + +

      #number XSpace : +The space on the X-axis in meters between each group.

      + +
    • +
    • + +

      #nubmer YSpace : +The start position on the Y-axis in meters for each group.

      + +
    • +
    • + +

      #number ZSpace : +The start position on the Z-axis in meters for each group.

      + +
    • +
    +

    Return value

    + +

    #boolean:

    + +
    @@ -546,6 +1186,294 @@ If true, then the direction vector will be smoked.

    + +AI_FORMATION:__FormationLeftLine(Delay) + +
    +
    + +

    FormationLeftLine Asynchronous Trigger for AI_FORMATION

    + +

    Parameter

    +
      +
    • + +

      #number Delay :

      + +
    • +
    +
    +
    +
    +
    + + +AI_FORMATION:__FormationLeftWing(Delay) + +
    +
    + +

    FormationLeftWing Asynchronous Trigger for AI_FORMATION

    + +

    Parameter

    +
      +
    • + +

      #number Delay :

      + +
    • +
    +
    +
    +
    +
    + + +AI_FORMATION:__FormationRightLine(Delay) + +
    +
    + +

    FormationRightLine Asynchronous Trigger for AI_FORMATION

    + +

    Parameter

    +
      +
    • + +

      #number Delay :

      + +
    • +
    +
    +
    +
    +
    + + +AI_FORMATION:__FormationRightWing(Delay) + +
    +
    + +

    FormationRightWing Asynchronous Trigger for AI_FORMATION

    + +

    Parameter

    +
      +
    • + +

      #number Delay :

      + +
    • +
    +
    +
    +
    +
    + + +AI_FORMATION:onafterFormationLeftLine(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +
    +
    + + + +

    Parameters

    +
      +
    • + +

      FollowGroupSet :

      + +
    • +
    • + +

      From :

      + +
    • +
    • + +

      Event :

      + +
    • +
    • + +

      To :

      + +
    • +
    • + +

      XSpace :

      + +
    • +
    • + +

      YSpace :

      + +
    • +
    • + +

      ZSpace :

      + +
    • +
    +
    +
    +
    +
    + + +AI_FORMATION:onafterFormationLeftWing(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +
    +
    + + + +

    Parameters

    +
      +
    • + +

      FollowGroupSet :

      + +
    • +
    • + +

      From :

      + +
    • +
    • + +

      Event :

      + +
    • +
    • + +

      To :

      + +
    • +
    • + +

      XSpace :

      + +
    • +
    • + +

      YSpace :

      + +
    • +
    • + +

      ZSpace :

      + +
    • +
    +
    +
    +
    +
    + + +AI_FORMATION:onafterFormationRightLine(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +
    +
    + + + +

    Parameters

    +
      +
    • + +

      FollowGroupSet :

      + +
    • +
    • + +

      From :

      + +
    • +
    • + +

      Event :

      + +
    • +
    • + +

      To :

      + +
    • +
    • + +

      XSpace :

      + +
    • +
    • + +

      YSpace :

      + +
    • +
    • + +

      ZSpace :

      + +
    • +
    +
    +
    +
    +
    + + +AI_FORMATION:onafterFormationRightWing(FollowGroupSet, From, Event, To, XSpace, YSpace, ZSpace) + +
    +
    + + + +

    Parameters

    +
      +
    • + +

      FollowGroupSet :

      + +
    • +
    • + +

      From :

      + +
    • +
    • + +

      Event :

      + +
    • +
    • + +

      To :

      + +
    • +
    • + +

      XSpace :

      + +
    • +
    • + +

      YSpace :

      + +
    • +
    • + +

      ZSpace :

      + +
    • +
    +
    +
    +
    +
    + AI_FORMATION:onenterFollowing(FollowGroupSet) @@ -663,6 +1591,8 @@ If true, then the direction vector will be smoked.

    +

    Type nubmer

    + diff --git a/docs/Documentation/AI_Patrol.html b/docs/Documentation/AI_Patrol.html index bebc26831..4b91533d8 100644 --- a/docs/Documentation/AI_Patrol.html +++ b/docs/Documentation/AI_Patrol.html @@ -953,6 +953,9 @@ Use the method AIPATROLZONE.M + +

    This table contains the targets detected during patrol.

    +
    diff --git a/docs/Documentation/Cargo.html b/docs/Documentation/Cargo.html index 8fadae3b5..0cf77d270 100644 --- a/docs/Documentation/Cargo.html +++ b/docs/Documentation/Cargo.html @@ -3046,7 +3046,6 @@ The range till cargo will board.

    - #number CARGO_UNIT.RunCount diff --git a/docs/Documentation/Detection.html b/docs/Documentation/Detection.html index 62e57668f..c21d35a8d 100644 --- a/docs/Documentation/Detection.html +++ b/docs/Documentation/Detection.html @@ -2337,7 +2337,6 @@ The index of the DetectedItem.

    - #number DETECTION_BASE.DetectedItemMax diff --git a/docs/Documentation/Fsm.html b/docs/Documentation/Fsm.html index f0ab48a01..2807d80e3 100644 --- a/docs/Documentation/Fsm.html +++ b/docs/Documentation/Fsm.html @@ -1624,7 +1624,7 @@ A string defining the start state.

    - #string + FSM._StartState @@ -1923,6 +1923,7 @@ A string defining the start state.

    + FSM.current diff --git a/docs/Documentation/Movement.html b/docs/Documentation/Movement.html index c732cbe69..eb07aae68 100644 --- a/docs/Documentation/Movement.html +++ b/docs/Documentation/Movement.html @@ -215,6 +215,7 @@ on defined intervals (currently every minute).

    + #number MOVEMENT.AliveUnits @@ -223,6 +224,9 @@ on defined intervals (currently every minute).

    + +

    Contains the counter how many units are currently alive

    +
    diff --git a/docs/Documentation/Spawn.html b/docs/Documentation/Spawn.html index 4a10c8567..0d752635f 100644 --- a/docs/Documentation/Spawn.html +++ b/docs/Documentation/Spawn.html @@ -772,6 +772,12 @@ and any spaces before and after the resulting name are removed.

    SPAWN:_TranslateRotate(SpawnIndex, SpawnRootX, SpawnRootY, SpawnX, SpawnY, SpawnAngle) + + + + SPAWN.uncontrolled + + @@ -2529,9 +2535,6 @@ when nothing was spawned.

    - -

    Overwrite unit names by default with group name.

    -
    @@ -2546,9 +2549,6 @@ when nothing was spawned.

    - -

    By default, no InitLimit

    -
    @@ -2584,7 +2584,7 @@ when nothing was spawned.

    - #number + SPAWN.SpawnMaxGroups @@ -2601,7 +2601,7 @@ when nothing was spawned.

    - #number + SPAWN.SpawnMaxUnitsAlive @@ -2929,7 +2929,7 @@ Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Schedule( 600, 0.5 )
    - + #boolean SPAWN.SpawnUnControlled @@ -3519,6 +3519,20 @@ True = Continue Scheduler

    + +
    +
    +
    + + + +SPAWN.uncontrolled + +
    +
    + + +
    diff --git a/docs/Documentation/SpawnStatic.html b/docs/Documentation/SpawnStatic.html index 69a9412e9..8750f8d57 100644 --- a/docs/Documentation/SpawnStatic.html +++ b/docs/Documentation/SpawnStatic.html @@ -446,7 +446,6 @@ ptional) The name of the new static.

    - #number SPAWNSTATIC.SpawnIndex diff --git a/docs/Documentation/Task_Cargo.html b/docs/Documentation/Task_Cargo.html index 5c03c9d31..64abe7762 100644 --- a/docs/Documentation/Task_Cargo.html +++ b/docs/Documentation/Task_Cargo.html @@ -503,7 +503,7 @@ based on the tasking capabilities defined in Task#TA
    - + Core.Cargo#CARGO_GROUP FSM_PROCESS.Cargo From 2c4a33aacb6993a088b85379a3e6f113d72dc57b Mon Sep 17 00:00:00 2001 From: FlightControl Date: Thu, 11 May 2017 12:38:24 +0200 Subject: [PATCH 2/2] Fixes --- Moose Development/Moose/AI/AI_Formation.lua | 176 +++++++++++++------- 1 file changed, 115 insertions(+), 61 deletions(-) diff --git a/Moose Development/Moose/AI/AI_Formation.lua b/Moose Development/Moose/AI/AI_Formation.lua index d3a18880a..7c31c16f3 100644 --- a/Moose Development/Moose/AI/AI_Formation.lua +++ b/Moose Development/Moose/AI/AI_Formation.lua @@ -143,9 +143,10 @@ function AI_FORMATION:New( FollowUnit, FollowGroupSet, FollowName, FollowBriefin -- @param #string From -- @param #string Event -- @param #string To - -- @param #number XSpace The space on the X-axis in meters between each group. - -- @param #nubmer YSpace The start position on the Y-axis in meters for each group. - -- @param #number ZSpace The start position on the Z-axis in meters for each group. + -- @param #number XStart The start position on the X-axis in meters for the first group. + -- @param #nubmer YStart The start position on the Y-axis in meters for the first group. + -- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. + -- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. -- @return #boolean --- FormationLeftLine Handler OnAfter for AI_FORMATION @@ -155,18 +156,27 @@ function AI_FORMATION:New( FollowUnit, FollowGroupSet, FollowName, FollowBriefin -- @param #string From -- @param #string Event -- @param #string To - -- @param #number XSpace The space on the X-axis in meters between each group. - -- @param #nubmer YSpace The start position on the Y-axis in meters for each group. - -- @param #number ZSpace The start position on the Z-axis in meters for each group. + -- @param #number XStart The start position on the X-axis in meters for the first group. + -- @param #nubmer YStart The start position on the Y-axis in meters for the first group. + -- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. + -- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. --- FormationLeftLine Trigger for AI_FORMATION -- @function [parent=#AI_FORMATION] FormationLeftLine -- @param #AI_FORMATION self + -- @param #number XStart The start position on the X-axis in meters for the first group. + -- @param #nubmer YStart The start position on the Y-axis in meters for the first group. + -- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. + -- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. --- FormationLeftLine Asynchronous Trigger for AI_FORMATION -- @function [parent=#AI_FORMATION] __FormationLeftLine -- @param #AI_FORMATION self -- @param #number Delay + -- @param #number XStart The start position on the X-axis in meters for the first group. + -- @param #nubmer YStart The start position on the Y-axis in meters for the first group. + -- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. + -- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. self:AddTransition( "*", "FormationRightLine", "*" ) @@ -178,9 +188,10 @@ function AI_FORMATION:New( FollowUnit, FollowGroupSet, FollowName, FollowBriefin -- @param #string From -- @param #string Event -- @param #string To - -- @param #number XSpace The space on the X-axis in meters between each group. - -- @param #nubmer YSpace The start position on the Y-axis in meters for each group. - -- @param #number ZSpace The start position on the Z-axis in meters for each group. + -- @param #number XStart The start position on the X-axis in meters for the first group. + -- @param #nubmer YStart The start position on the Y-axis in meters for the first group. + -- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. + -- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. -- @return #boolean --- FormationRightLine Handler OnAfter for AI_FORMATION @@ -190,18 +201,27 @@ function AI_FORMATION:New( FollowUnit, FollowGroupSet, FollowName, FollowBriefin -- @param #string From -- @param #string Event -- @param #string To - -- @param #number XSpace The space on the X-axis in meters between each group. - -- @param #nubmer YSpace The start position on the Y-axis in meters for each group. - -- @param #number ZSpace The start position on the Z-axis in meters for each group. + -- @param #number XStart The start position on the X-axis in meters for the first group. + -- @param #nubmer YStart The start position on the Y-axis in meters for the first group. + -- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. + -- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. --- FormationRightLine Trigger for AI_FORMATION -- @function [parent=#AI_FORMATION] FormationRightLine -- @param #AI_FORMATION self + -- @param #number XStart The start position on the X-axis in meters for the first group. + -- @param #nubmer YStart The start position on the Y-axis in meters for the first group. + -- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. + -- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. --- FormationRightLine Asynchronous Trigger for AI_FORMATION -- @function [parent=#AI_FORMATION] __FormationRightLine -- @param #AI_FORMATION self -- @param #number Delay + -- @param #number XStart The start position on the X-axis in meters for the first group. + -- @param #nubmer YStart The start position on the Y-axis in meters for the first group. + -- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. + -- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. self:AddTransition( "*", "FormationLeftWing", "*" ) @@ -212,9 +232,11 @@ function AI_FORMATION:New( FollowUnit, FollowGroupSet, FollowName, FollowBriefin -- @param #string From -- @param #string Event -- @param #string To - -- @param #number XSpace The space on the X-axis in meters between each group. - -- @param #nubmer YSpace The start position on the Y-axis in meters for each group. - -- @param #number ZSpace The start position on the Z-axis in meters for each group. + -- @param #number XStart The start position on the X-axis in meters for the first group. + -- @param #number XSpace The space between groups on the X-axis in meters for each sequent group. + -- @param #nubmer YStart The start position on the Y-axis in meters for the first group. + -- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. + -- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. -- @return #boolean --- FormationLeftWing Handler OnAfter for AI_FORMATION @@ -224,18 +246,30 @@ function AI_FORMATION:New( FollowUnit, FollowGroupSet, FollowName, FollowBriefin -- @param #string From -- @param #string Event -- @param #string To - -- @param #number XSpace The space on the X-axis in meters between each group. - -- @param #nubmer YSpace The start position on the Y-axis in meters for each group. - -- @param #number ZSpace The start position on the Z-axis in meters for each group. + -- @param #number XStart The start position on the X-axis in meters for the first group. + -- @param #number XSpace The space between groups on the X-axis in meters for each sequent group. + -- @param #nubmer YStart The start position on the Y-axis in meters for the first group. + -- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. + -- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. --- FormationLeftWing Trigger for AI_FORMATION -- @function [parent=#AI_FORMATION] FormationLeftWing -- @param #AI_FORMATION self + -- @param #number XStart The start position on the X-axis in meters for the first group. + -- @param #number XSpace The space between groups on the X-axis in meters for each sequent group. + -- @param #nubmer YStart The start position on the Y-axis in meters for the first group. + -- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. + -- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. --- FormationLeftWing Asynchronous Trigger for AI_FORMATION -- @function [parent=#AI_FORMATION] __FormationLeftWing -- @param #AI_FORMATION self -- @param #number Delay + -- @param #number XStart The start position on the X-axis in meters for the first group. + -- @param #number XSpace The space between groups on the X-axis in meters for each sequent group. + -- @param #nubmer YStart The start position on the Y-axis in meters for the first group. + -- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. + -- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. self:AddTransition( "*", "FormationRightWing", "*" ) @@ -247,9 +281,11 @@ function AI_FORMATION:New( FollowUnit, FollowGroupSet, FollowName, FollowBriefin -- @param #string From -- @param #string Event -- @param #string To - -- @param #number XSpace The space on the X-axis in meters between each group. - -- @param #nubmer YSpace The start position on the Y-axis in meters for each group. - -- @param #number ZSpace The start position on the Z-axis in meters for each group. + -- @param #number XStart The start position on the X-axis in meters for the first group. + -- @param #number XSpace The space between groups on the X-axis in meters for each sequent group. + -- @param #nubmer YStart The start position on the Y-axis in meters for the first group. + -- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. + -- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. -- @return #boolean --- FormationRightWing Handler OnAfter for AI_FORMATION @@ -259,26 +295,35 @@ function AI_FORMATION:New( FollowUnit, FollowGroupSet, FollowName, FollowBriefin -- @param #string From -- @param #string Event -- @param #string To - -- @param #number XSpace The space on the X-axis in meters between each group. - -- @param #nubmer YSpace The start position on the Y-axis in meters for each group. - -- @param #number ZSpace The start position on the Z-axis in meters for each group. + -- @param #number XStart The start position on the X-axis in meters for the first group. + -- @param #number XSpace The space between groups on the X-axis in meters for each sequent group. + -- @param #nubmer YStart The start position on the Y-axis in meters for the first group. + -- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. + -- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. --- FormationRightWing Trigger for AI_FORMATION -- @function [parent=#AI_FORMATION] FormationRightWing -- @param #AI_FORMATION self + -- @param #number XStart The start position on the X-axis in meters for the first group. + -- @param #number XSpace The space between groups on the X-axis in meters for each sequent group. + -- @param #nubmer YStart The start position on the Y-axis in meters for the first group. + -- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. + -- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. --- FormationRightWing Asynchronous Trigger for AI_FORMATION -- @function [parent=#AI_FORMATION] __FormationRightWing -- @param #AI_FORMATION self -- @param #number Delay - - - + -- @param #number XStart The start position on the X-axis in meters for the first group. + -- @param #number XSpace The space between groups on the X-axis in meters for each sequent group. + -- @param #nubmer YStart The start position on the Y-axis in meters for the first group. + -- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. + -- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. self:AddTransition( "*", "Follow", "Following" ) - self:FormationLeftLine( 50, 0, 100 ) + self:FormationLeftLine( 500, 0, 250, 250 ) self.FollowName = FollowName self.FollowBriefing = FollowBriefing @@ -309,11 +354,12 @@ end -- @param #string From -- @param #string Event -- @param #string To --- @param #number XSpace The space on the X-axis in meters between each group. --- @param #nubmer YSpace The start position on the Y-axis in meters for each group. --- @param #number ZSpace The start position on the Z-axis in meters for each group. -function AI_FORMATION:onafterFormationLeftLine( FollowGroupSet, From , Event , To, XSpace, YSpace, ZSpace ) - self:E( { FollowGroupSet, From , Event , To, XSpace, YSpace, ZSpace } ) +-- @param #number XStart The start position on the X-axis in meters for the first group. +-- @param #nubmer YStart The start position on the Y-axis in meters for the first group. +-- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. +-- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. +function AI_FORMATION:onafterFormationLeftLine( FollowGroupSet, From , Event , To, XStart, YStart, ZStart, ZSpace ) + self:E( { FollowGroupSet, From , Event ,To, XStart, YStart, ZStart, ZSpace } ) FollowGroupSet:Flush() @@ -324,9 +370,9 @@ function AI_FORMATION:onafterFormationLeftLine( FollowGroupSet, From , Event , T for FollowID, FollowGroup in pairs( FollowSet ) do local PointVec3 = POINT_VEC3:New() - PointVec3:SetX( -XSpace ) - PointVec3:SetY( YSpace ) - PointVec3:SetZ( i * ZSpace ) + PointVec3:SetX( XStart ) + PointVec3:SetY( YStart ) + PointVec3:SetZ( ZStart + i * ZSpace ) local Vec3 = PointVec3:GetVec3() self:E( Vec3 ) @@ -340,16 +386,18 @@ end --- FormationRightLine Handler OnAfter for AI_FORMATION --- @function [parent=#AI_FORMATION] OnAfterFormationLeftLine +-- @function [parent=#AI_FORMATION] OnAfterFormationRightLine -- @param #AI_FORMATION self -- @param Core.Set#SET_GROUP FollowGroupSet The group AI escorting the FollowUnit. -- @param #string From -- @param #string Event -- @param #string To --- @param #number XSpace The space on the X-axis in meters between each group. --- @param #nubmer YSpace The start position on the Y-axis in meters for each group. --- @param #number ZSpace The start position on the Z-axis in meters for each group. -function AI_FORMATION:onafterFormationRightLine( FollowGroupSet, From , Event , To, XSpace, YSpace, ZSpace ) +-- @param #number XStart The start position on the X-axis in meters for the first group. +-- @param #nubmer YStart The start position on the Y-axis in meters for the first group. +-- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. +-- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. +function AI_FORMATION:onafterFormationRightLine( FollowGroupSet, From , Event , To, XStart, YStart, ZStart, ZSpace ) + self:E( { FollowGroupSet, From , Event , To, XStart, YStart, ZStart, ZSpace } ) local FollowSet = FollowGroupSet:GetSet() @@ -358,9 +406,9 @@ function AI_FORMATION:onafterFormationRightLine( FollowGroupSet, From , Event , for FollowID, FollowGroup in pairs( FollowSet ) do local PointVec3 = POINT_VEC3:New() - PointVec3:SetX( i * XSpace ) - PointVec3:SetY( YSpace ) - PointVec3:SetZ( -ZSpace ) + PointVec3:SetX( XStart ) + PointVec3:SetY( YStart ) + PointVec3:SetZ( -(ZStart + i * ZSpace) ) local Vec3 = PointVec3:GetVec3() self:E( Vec3 ) @@ -380,10 +428,12 @@ end -- @param #string From -- @param #string Event -- @param #string To --- @param #number XSpace The space on the X-axis in meters between each group. --- @param #nubmer YSpace The start position on the Y-axis in meters for each group. --- @param #number ZSpace The start position on the Z-axis in meters for each group. -function AI_FORMATION:onafterFormationLeftWing( FollowGroupSet, From , Event , To, XSpace, YSpace, ZSpace ) +-- @param #number XStart The start position on the X-axis in meters for the first group. +-- @param #number XSpace The space between groups on the X-axis in meters for each sequent group. +-- @param #nubmer YStart The start position on the Y-axis in meters for the first group. +-- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. +-- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. +function AI_FORMATION:onafterFormationLeftWing( FollowGroupSet, From , Event , To, XStart, XSpace, YStart, ZStart, ZSpace ) local FollowSet = FollowGroupSet:GetSet() @@ -392,9 +442,9 @@ function AI_FORMATION:onafterFormationLeftWing( FollowGroupSet, From , Event , T for FollowID, FollowGroup in pairs( FollowSet ) do local PointVec3 = POINT_VEC3:New() - PointVec3:SetX( -i * XSpace ) - PointVec3:SetY( i * YSpace ) - PointVec3:SetZ( -ZSpace ) + PointVec3:SetX( XStart + i * XSpace ) + PointVec3:SetY( YStart ) + PointVec3:SetZ( ZStart + i * ZSpace ) local Vec3 = PointVec3:GetVec3() self:E( Vec3 ) @@ -408,16 +458,18 @@ end --- FormationRightWing Handler OnAfter for AI_FORMATION --- @function [parent=#AI_FORMATION] OnAfterFormationLeftWing +-- @function [parent=#AI_FORMATION] OnAfterFormationRightWing -- @param #AI_FORMATION self -- @param Core.Set#SET_GROUP FollowGroupSet The group AI escorting the FollowUnit. -- @param #string From -- @param #string Event -- @param #string To --- @param #number XSpace The space on the X-axis in meters between each group. --- @param #nubmer YSpace The start position on the Y-axis in meters for each group. --- @param #number ZSpace The start position on the Z-axis in meters for each group. -function AI_FORMATION:onafterFormationRightWing( FollowGroupSet, From , Event , To, XSpace, YSpace, ZSpace ) +-- @param #number XStart The start position on the X-axis in meters for the first group. +-- @param #number XSpace The space between groups on the X-axis in meters for each sequent group. +-- @param #nubmer YStart The start position on the Y-axis in meters for the first group. +-- @param #nubmer ZStart The start position on the Z-axis in meters for the first group. +-- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group. +function AI_FORMATION:onafterFormationRightWing( FollowGroupSet, From , Event , To, XStart, XSpace, YStart, ZStart, ZSpace ) local FollowSet = FollowGroupSet:GetSet() @@ -426,10 +478,10 @@ function AI_FORMATION:onafterFormationRightWing( FollowGroupSet, From , Event , for FollowID, FollowGroup in pairs( FollowSet ) do local PointVec3 = POINT_VEC3:New() - PointVec3:SetX( i * XSpace ) - PointVec3:SetY( i * YSpace ) - PointVec3:SetZ( -ZSpace ) - + PointVec3:SetX( XStart + i * XSpace ) + PointVec3:SetY( YStart ) + PointVec3:SetZ( -(ZStart + i * ZSpace) ) + local Vec3 = PointVec3:GetVec3() self:E( Vec3 ) FollowGroup:SetState( self, "Vec3", Vec3 ) @@ -441,6 +493,8 @@ function AI_FORMATION:onafterFormationRightWing( FollowGroupSet, From , Event , end + + --- @param Follow#AI_FORMATION self function AI_FORMATION:onenterFollowing( FollowGroupSet ) self:F( ) @@ -555,7 +609,7 @@ function AI_FORMATION:onenterFollowing( FollowGroupSet ) -- The calculation of the Speed would simulate that the group would take 30 seconds to overcome -- the requested Distance). local Time = 10 - local CatchUpSpeed = ( CatchUpDistance - ( CS * 20 ) ) / Time + local CatchUpSpeed = ( CatchUpDistance - ( CS * 15 ) ) / Time local Speed = CS + CatchUpSpeed if Speed < 0 then