Jump to content

Recommended Posts

Posted (edited)

OK, with your help Everyone, I'm learning a ton about MOOSE but still have a long ways to go! With all your help, I was able to make this script work for uncontrolled, late SPAWNED groups you see below in the code. This script allows 3 uncontrolled, late-SPAWNED groups to follow the same SPAWNED leading group and is working perfectly. See below...

 

local LARGCL = POINT_VEC3:New( 0, 0, 914.4 )

local LARCL = POINT_VEC3:New( 0, 0, 1828.8 )

local LAROL = POINT_VEC3:New( 0, 0, 2743.2 )

 

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

 

GP_FOLLOW( Fw190D9GP4JG301, Fw190D9GP5JG301, LARGCL )

GP_FOLLOW( Fw190D9GP4JG301, Fw190D9GP6JG301, LARCL )

GP_FOLLOW( Fw190D9GP4JG301, Fw190D9GP7JG301, LAROL )

 

 

NOW, I want to do the same thing with groups that ALREADY EXIST in mission (not spawned).... I want to use the same 4 groups that are NOT late activated, but already exist at mission start. Any ideas anyone to make simple changes to this code???? I await your enlightenment... ChuckIV

 

On a side note... I saw this coding online and tried this as well, but no luck...

 

function CONTROLLABLE:TaskFollow( FollowControllable, Vec3 )

self:F2( { self.ControllableName, FollowControllable, Vec3 } )

local DCSTask

DCSTask = { id = 'Follow', params = { groupId = FollowControllable:GetID(), pos = Vec3 } }

self:T3( { DCSTask } )

return DCSTask

end

Fw190D9GP5JG301:TaskFollow( Fw190D9GP4JG301, LARGCL )

Fw190D9GP6JG301:TaskFollow( Fw190D9GP4JG301, LARCL )

Fw190D9GP7JG301:TaskFollow( Fw190D9GP4JG301, LAROL )

Edited by ChuckIV
changed sentence order

"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)

You need to find the relevant existing units (they must be alive when the script runs) and task them the same way you did with the spawned groups.

 

There's a chance the AI won't switch tasks when doing FollowingGP:SetTask( GP_Task, 1 ), in that case, you can try clearing their current tasks immediately before, using :ClearTasks()

 

Also, if you define the offsets in vec3 format, there's no need to use :GetVec3() in the task declaration.

 

[color="blue"]-- Define offsets in DCS Vec3 format[/color]

local LARGCL = { x = 0, y = 0, z = 914.4 } 
local LARCL = { x = 0, y = 0, z = 1828.8  }
local LAROL = { x = 0, y = 0, z = 2743.2 }


[color="blue"]-- Define GP_FOLLOW function[/color]

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 ) [color="blue"]-- Note that [i][b]:GetVec3()[/b][/i] is no longer needed, since the offsets are already declared in Vec3 format[/color]
   
  ---FollowingGP:ClearTasks() [color="Blue"]-- Use this line ONLY if you have trouble getting the following groups to switch task[/color]
   FollowingGP:SetTask( GP_Task, 1 )
end


[color="blue"]-- Define following and followed groups (they all must be alive when this script runs)[/color]

local Following_Grp_1 = GROUP:FindByName("[color="Red"]name of the first following group in ME[/color]")
local Following_Grp_2 = GROUP:FindByName("[color="Red"]name of the second following group in ME[/color]")
local Following_Grp_3 = GROUP:FindByName("[color="Red"]name of the third following group in ME[/color]")
local Following_Grp_4 = GROUP:FindByName("[color="Red"]name of the fourth following group in ME[/color]")
[color="Blue"]-- etc...[/color]

local Followed_Grp_1 = GROUP:FindByName("[color="Red"]name of the first followed group in ME[/color]")
[color="Blue"]-- etc...[/color]

[color="blue"]-- Call GP_FOLLOW function with the desired parameters[/color]

GP_FOLLOW( Followed_Grp_1 , Following_Grp_1 , LARGCL )
GP_FOLLOW( Followed_Grp_1 , Following_Grp_2 , LARCL )
GP_FOLLOW( Followed_Grp_1 , Following_Grp_3 , LAROL )
GP_FOLLOW( Followed_Grp_1 , Following_Grp_4 , LAROL )

Edited by Hardcard
Posted

THANK YOU HARDCARD!

 

HardCard,

 

I changed all the offsets to DCS Vec3 format like you suggested. Then, after removing the :GetVec3(), I changed all the Group.getByName to GROUP:FindByName for the groups in the ME.

 

*** I thought Group.getByName was for SPAWNED aircraft only and GROUP:FindByName was for EXISTING aircraft at startup only. ?????

 

HardCard, can you explain to me the difference of these two definition methods?? This is what caused my problem.

 

ChuckIV

"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

  • Recently Browsing   0 members

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