Jump to content

Can an AI group FOLLOW another AI group?? Help!


Recommended Posts

Posted

I would simply like a spawned AI group named Spitfire_GP10_P9374 to follow another spawned AI group named Spitfire_GP3_P9374

 

Here is the code I've got so far... ANY IDEA why the spawned AI group Spitfire_GP10_P9374 will not follow the other spawned AI group Spitfire_GP3_P9374??? ANY HELP would be greatly appreciated!!! ChuckIV Here's the code...

 

do

 

local LARCL = POINT_VEC3:New( 0, 0, 914.4 ) -- Line abreast right close level

 

function GP_FOLLOW( Following_GP, Vec3 ) -- Function for a group to follow another

local GP_Offset = Vec3

local GP_Task = Following_GP:TaskFollow( Spitfire_GP3_P9374, GP_Offset:GetVec3() )

Following_GP:SetTask( GP_Task, 1 )

end

 

GP_FOLLOW( Spitfire_GP10_P9374, LARCL )

 

end

"Never in the field of human conflict was so much owed by so many to so few." Winston Churchill

 

SYSTEM:

Processor - Intel® Core i9-9900KF CPU @ 3.60GHz 3600MHz water-cooled

Installed memory (RAM) - 32.0 GB

64-bit Operating System, x64-based processor

Windows 10 & DCS on SSD

Video Card - water-cooled NVIDIA GeForce RTX 2080 Ti

Internet: Cable 200Mbps 12Mbps

Posted (edited)

At first glance, my guess would be that you didn't provide the required parameters for :TaskFollow

 

UNIT/GROUP:TaskFollow(FollowControllable , [color="Red"]DCS Vec3[/color] , [color="Red"]LastWaypointIndex[/color])

 

Here's the Hoggit wiki article: https://wiki.hoggitworld.com/view/DCS_task_follow

 

 

Also, you'd need to provide the specific spawning method for the AI group and the declaration for Spitfire_GP10_P9374 .

If you're using MOOSE SPAWN class to do it, you might have problems with group naming as well.

Edited by Hardcard
Posted

TAKE A LOOK

 

OK, here's what I've got so far... This is my .lua file that gets loaded 5 seconds into the mission after loading moose.lua....

 

do

local Spitfire_GP3_P9374 = SPAWN:New( "Spitfire GP3 P9374" ):InitRandomizePosition(false):InitLimit( 500, 1 ):InitRepeatOnEngineShutDown():SpawnScheduled( 1, 0 )

local Spitfire_GP10_P9374 = SPAWN:New( "Spitfire GP10 P9374" ):InitRandomizePosition(false):InitLimit( 500, 1 ):InitRepeatOnEngineShutDown():SpawnScheduled( 1, 0 )

 

-- ***************************** DEFINE VEC3 POINT FOR FOLLOWING GROUPS ***************************************************************

local LARCL = POINT_VEC3:New( 0, 0, 914.4 ) -- LINE ABREAST RIGHT CLOSE LEVEL

 

-- ******************************** FUNCTION FOR GROUP TO FOLLOW ANOTHER GROUP **********************************************************

function GP_FOLLOW( Followed_GP, Following_GP, Vec3 )

local FollowedGP = group.getByName( Followed_GP )

local FollowingGP = group.getByName( Following_GP )

local GP_Offset = Vec3

local GP_Task = FollowingGP:TaskFollow( FollowedGP, GP_Offset:GetVec3() )

FollowingGP:SetTask( GP_Task, 1 )

end

 

-- ******************************************** SPAWN GROUPS ****************************************************************************

Spitfire_GP3_P9374:SPAWN()

Spitfire_GP10_P9374:SPAWN()

 

-- **************************************** SET GROUPS TO FOLLOW ************************************************************************

GP_FOLLOW( Spitfire_GP3_P9374 , Spitfire_GP10_P9374 , LARCL )

end

 

 

fefifofum, I've added your group.getByName() into the function GP_FOLLOW, but still no luck. I've attached the .miz file as well as this .lua file so you can see how GP10 does not follow GP3; he just RTB's after his 1st WP.

 

Any ideas guys?? ChuckIV

TEST - SPAWN ALLIED AIRCRAFT 1940.lua

TEST - Battle of Britain - Royal Navy - 1940.miz

"Never in the field of human conflict was so much owed by so many to so few." Winston Churchill

 

SYSTEM:

Processor - Intel® Core i9-9900KF CPU @ 3.60GHz 3600MHz water-cooled

Installed memory (RAM) - 32.0 GB

64-bit Operating System, x64-based processor

Windows 10 & DCS on SSD

Video Card - water-cooled NVIDIA GeForce RTX 2080 Ti

Internet: Cable 200Mbps 12Mbps

Posted (edited)

There is no following_GP or followed_GP defined...right now it looks like they are just looking at each other but neither exist. You need to point those to an actual in-game active group.

 

So followedGP = group.getByName ('SpitfireGroup') where 'SpitfireGroup' is the name of a group as typed in the Mission Editor.

 

I believe MOOSE can also automatically store and index a table of units as they are spawned, which will probably be an easier way to access them if everything is dynamically generated. Have to check with the MOOSE crew (Delta, HardCard and Pikey come to mind) for further details on that. Try joining the MOOSE discord group and asking on there, very helpful bunch.

Edited by feefifofum
Posted (edited)

SOLUTION (old solution actually)

 

FOUND a SOLUTION!!! I went WAY back to a post that had the exact same question/problem. Here is the code that allows a SPAWNED AI GROUP to follow another SPAWNED AI GROUP...

 

do

local Spitfire_GP3_P9374 = SPAWN:New( 'Spitfire GP3 P9374' )

local Spitfire_GP10_P9374 = SPAWN:New( 'Spitfire GP10 P9374' )

 

-- ***************************** DEFINE VEC3 POINT FOR FOLLOWING GROUPS ***************************************************************

local LARCL = POINT_VEC3:New( 0, 0, 914.4 ) -- LINE ABREAST RIGHT CLOSE LEVEL

 

-- ******************************** FUNCTION FOR GROUP TO FOLLOW ANOTHER GROUP **********************************************************

function GP_FOLLOW( Followed_GP, Following_GP, Vec3 )

local FollowedGP = Followed_GP

local FollowingGP = Following_GP

local GP_Offset = Vec3

local GP_Task = FollowingGP:TaskFollow( FollowedGP, GP_Offset:GetVec3() )

FollowingGP:SetTask( GP_Task, 1 )

end

 

-- ******************************************** SPAWN GROUPS ****************************************************************************

local SpitfireGP3P9374 = Spitfire_GP3_P9374:Spawn()

local SpitfireGP10P9374 = Spitfire_GP10_P9374:Spawn()

 

-- **************************************** SET GROUPS TO FOLLOW ************************************************************************

GP_FOLLOW( SpitfireGP3P9374 , SpitfireGP10P9374 , LARCL )

end

 

**** Now, it's onto figuring out how to make these groups respawn and continue to follow ****

Edited by ChuckIV
Added text

"Never in the field of human conflict was so much owed by so many to so few." Winston Churchill

 

SYSTEM:

Processor - Intel® Core i9-9900KF CPU @ 3.60GHz 3600MHz water-cooled

Installed memory (RAM) - 32.0 GB

64-bit Operating System, x64-based processor

Windows 10 & DCS on SSD

Video Card - water-cooled NVIDIA GeForce RTX 2080 Ti

Internet: Cable 200Mbps 12Mbps

Posted (edited)

@ChuckIV

 

There are several problems with your previous script (wrong syntax, wrong parameters, objects given instead of strings, incompatible objects, etc).

 

 

Here you have a corrected and "simplified" version:

 

 local GP3_Table = {}

 local GP10_Table = {}

 local Spitfire_GP3_P9374 = SPAWN:New( "Spitfire GP3 P9374" )
 :OnSpawnGroup(
 function(Spitfire_GP3) 
    
    table.insert(GP3_Table , Spitfire_GP3)
 end
 )
 
 local Spitfire_GP10_P9374 = SPAWN:New( "Spitfire GP10 P9374" )
 :OnSpawnGroup(
 function(Spitfire_GP10) 
    
    table.insert(GP10_Table , Spitfire_GP10)
 end
 )



[color="blue"]-- ***************************** DEFINE VEC3 POINT FOR FOLLOWING GROUPS *************************************************************** 
-- ******************************** FUNCTION FOR GROUP TO FOLLOW ANOTHER GROUP **********************************************************[/color]
 function GP_FOLLOW()
 
     for i, GP3 in ipairs(GP3_Table) do
         
         if GP3 and GP3:IsAlive() then
            
            local GP3_Position = GP3:GetPositionVec3()
            LARCL = { x = GP3_Position.x, y = GP3_Position.y , z = GP3_Position.z + 914.4 } [color="Blue"] -- Taking the position of GP3 as reference might not be necessary here...[/color]
            FollowedGP = GP3
          
          else   
            i = nil
         end
     end
     
     for k, GP10 in ipairs(GP10_Table) do
         
         if GP10 and GP10:IsAlive() and LARCL and FollowedGP then
            
            local FollowingGP = GP10
            local GP_Task = GP10:TaskFollow( FollowedGP , LARCL) [color="blue"]-- According to the Hoggit Wiki documentation, the parameters lastWptIndexFlag and lastWptIndex must be given as well, but you can try without them, see what happens [/color]  
            FollowingGP:SetTask( GP_Task, 1 )
         else   
            k = nil
         end
     end
 end

[color="blue"]-- ******************************************** SPAWN GROUPS **************************************************************************** [/color]
 Spitfire_GP3_P9374:Spawn()
 Spitfire_GP10_P9374:Spawn()

[color="blue"]-- **************************************** SET GROUPS TO FOLLOW ************************************************************************ [/color]
 GP_FOLLOW()

 

 

 

If you want to repeat the process with newly spawned groups, simply run the following lines again (previously spawned groups must be dead, though):

 

Spitfire_GP3_P9374:Spawn()
Spitfire_GP10_P9374:Spawn()
GP_FOLLOW()

Edited by Hardcard
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...