Carrier Strike Group

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
Zyph
Posts: 37
Joined: Mon Sep 12, 2022 6:58 pm

Carrier Strike Group

Post by Zyph »

Hello,

Im building a Carrier Strike Group with random names and proficiency (aircraft, destroyers, submarines and so on). I would like to center as much as possible around lat/long of the carrier so i just need input the carriers lat/lon and then use "relativeTo" or "World_GetPointFromBearing" for the other ships.Sombody has a easy solution to make Henry J Kaiser and USS Chicago bearing and distance to George Bush? So i dont need to change like 10 lat/lon coordinates when i need the group in some other part of the world...

--ADD CARRIER
ScenEdit_AddUnit({type='Ship', name='George Bush', heading =0, dbid =3225, side ='USA', Latitude="N69.00.00",Longitude="E10.00.00", altitude="0 ft", speed=0,proficiency=4})

--ADD Support ship
ScenEdit_AddUnit({type='Ship', name='Henry J. Kaiser 187', heading =180, speed=0, dbid =26, side ='USA', Latitude="N68.59.10",Longitude="E10.01.30", altitude="0 ft",proficiency=4})

--ADD Submarine SSN 700 Dallas [Los Angeles Class] 2008
ScenEdit_AddUnit({type='Submarine', name='USS Chicago', heading =0, speed=0, dbid =533, side ='USA', Latitude="N69.03.10",Longitude="E10.00.00", altitude="-300 ft",proficiency=3})
User avatar
TitaniumTrout
Posts: 472
Joined: Mon Oct 20, 2014 9:06 am
Location: Michigan

Re: Carrier Strike Group

Post by TitaniumTrout »

Zyph wrote: Mon Mar 20, 2023 11:15 pm Im building a Carrier Strike Group with random names and proficiency (aircraft, destroyers, submarines and so on). I would like to center as much as possible around lat/long of the carrier so i just need input the carriers lat/lon and then use "relativeTo" or "World_GetPointFromBearing" for the other ships.Sombody has a easy solution to make Henry J Kaiser and USS Chicago bearing and distance to George Bush? So i dont need to change like 10 lat/lon coordinates when i need the group in some other part of the world...
This is a fairly quick way to do it by using variables and random.

Code: Select all

local lat = '23.8611'
local lon = '-131.8288'
math.randomseed(os.time())

--ADD CARRIER
ScenEdit_AddUnit({type='Ship', name='George Bush', heading =0, dbid =3225, side ='USA', Latitude=lat,Longitude=lon, altitude="0 ft", speed=0,proficiency=4})

--ADD Support ship
ScenEdit_AddUnit({type='Ship', name='Henry J. Kaiser 187', heading =180, speed=0, dbid =26, side ='USA', Latitude=((math.random(10)/10)+lat+.020),Longitude=((math.random(5)/5)+lon-0.10), altitude="0 ft",proficiency=4})

--ADD Submarine SSN 700 Dallas [Los Angeles Class] 2008
ScenEdit_AddUnit({type='Submarine', name='USS Chicago', heading =0, speed=0, dbid =533, side ='USA', Latitude=((math.random(10)/10)+lat+0.30),Longitude=((math.random(6)/6)+lon+0.11), altitude="-300 ft",proficiency=3})

Zyph
Posts: 37
Joined: Mon Sep 12, 2022 6:58 pm

Re: Carrier Strike Group

Post by Zyph »

TitaniumTrout wrote: Tue Mar 21, 2023 12:39 am
Zyph wrote: Mon Mar 20, 2023 11:15 pm Im building a Carrier Strike Group with random names and proficiency (aircraft, destroyers, submarines and so on). I would like to center as much as possible around lat/long of the carrier so i just need input the carriers lat/lon and then use "relativeTo" or "World_GetPointFromBearing" for the other ships.Sombody has a easy solution to make Henry J Kaiser and USS Chicago bearing and distance to George Bush? So i dont need to change like 10 lat/lon coordinates when i need the group in some other part of the world...
This is a fairly quick way to do it by using variables and random.

Code: Select all

local lat = '23.8611'
local lon = '-131.8288'
math.randomseed(os.time())

--ADD CARRIER
ScenEdit_AddUnit({type='Ship', name='George Bush', heading =0, dbid =3225, side ='USA', Latitude=lat,Longitude=lon, altitude="0 ft", speed=0,proficiency=4})

--ADD Support ship
ScenEdit_AddUnit({type='Ship', name='Henry J. Kaiser 187', heading =180, speed=0, dbid =26, side ='USA', Latitude=((math.random(10)/10)+lat+.020),Longitude=((math.random(5)/5)+lon-0.10), altitude="0 ft",proficiency=4})

--ADD Submarine SSN 700 Dallas [Los Angeles Class] 2008
ScenEdit_AddUnit({type='Submarine', name='USS Chicago', heading =0, speed=0, dbid =533, side ='USA', Latitude=((math.random(10)/10)+lat+0.30),Longitude=((math.random(6)/6)+lon+0.11), altitude="-300 ft",proficiency=3})

Thank you! Not just optimal for what i have in mind. The plan is to have the USS Chicago 5 nm 0 degree in front of the carrier, Ticonderoga also front then Arleigh Burke classes on 45, 135, 225, 315 degrees from the Carrier with a distance around 6 nm from carrier and two Support ships just behind...
Attachments
Screenshot 2023-03-21 095252.jpg
Screenshot 2023-03-21 095252.jpg (393.26 KiB) Viewed 564 times
Zyph
Posts: 37
Joined: Mon Sep 12, 2022 6:58 pm

Re: Carrier Strike Group

Post by Zyph »

Zyph wrote: Tue Mar 21, 2023 1:45 am
TitaniumTrout wrote: Tue Mar 21, 2023 12:39 am
Zyph wrote: Mon Mar 20, 2023 11:15 pm Im building a Carrier Strike Group with random names and proficiency (aircraft, destroyers, submarines and so on). I would like to center as much as possible around lat/long of the carrier so i just need input the carriers lat/lon and then use "relativeTo" or "World_GetPointFromBearing" for the other ships.Sombody has a easy solution to make Henry J Kaiser and USS Chicago bearing and distance to George Bush? So i dont need to change like 10 lat/lon coordinates when i need the group in some other part of the world...
This is a fairly quick way to do it by using variables and random.

Code: Select all

local lat = '23.8611'
local lon = '-131.8288'
math.randomseed(os.time())

--ADD CARRIER
ScenEdit_AddUnit({type='Ship', name='George Bush', heading =0, dbid =3225, side ='USA', Latitude=lat,Longitude=lon, altitude="0 ft", speed=0,proficiency=4})

--ADD Support ship
ScenEdit_AddUnit({type='Ship', name='Henry J. Kaiser 187', heading =180, speed=0, dbid =26, side ='USA', Latitude=((math.random(10)/10)+lat+.020),Longitude=((math.random(5)/5)+lon-0.10), altitude="0 ft",proficiency=4})

--ADD Submarine SSN 700 Dallas [Los Angeles Class] 2008
ScenEdit_AddUnit({type='Submarine', name='USS Chicago', heading =0, speed=0, dbid =533, side ='USA', Latitude=((math.random(10)/10)+lat+0.30),Longitude=((math.random(6)/6)+lon+0.11), altitude="-300 ft",proficiency=3})

Thank you! Not just optimal for what i have in mind. The plan is to have the USS Chicago 5 nm 0 degree in front of the carrier, Ticonderoga also front then Arleigh Burke classes on 45, 135, 225, 315 degrees from the Carrier with a distance around 6 nm from carrier and two Support ships just behind...
Have been trying this out but cant get it to work...
local dist=6
local bear=45
local position = World_GetPointFromBearing({latitude='George Bush'.latitude,longitude='George Bush'.longitude,distance=dist,bearing=bear})
ScenEdit_AddUnit({type='Submarine', name='USS Chicago', heading =0, speed=0, dbid =533, side ='USA', Latitude=position.latitude, Longitude=position.latitude, altitude="-300 ft",proficiency=3})
User avatar
michaelm75au
Posts: 12455
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

Re: Carrier Strike Group

Post by michaelm75au »

I haven't tried it myself.
But would this work ...
1. Add the units in a bunch.
2. Then set the formation detail of each unit in the group giving the distance/bearing of the units from the group lead with the flag to jump to the location.
Michael
Zyph
Posts: 37
Joined: Mon Sep 12, 2022 6:58 pm

Re: Carrier Strike Group

Post by Zyph »

michaelm75au wrote: Tue Mar 21, 2023 5:57 pm I haven't tried it myself.
But would this work ...
1. Add the units in a bunch.
2. Then set the formation detail of each unit in the group giving the distance/bearing of the units from the group lead with the flag to jump to the location.
Found a solution after many trial and error:

--CVN 77 GEORGE BUSH - (mothership)
ScenEdit_AddUnit({type='Ship', name='George Bush', heading =0, dbid =3225, side ='USA', Latitude='N69.00.00',Longitude='E10.00.00', altitude='0 ft', speed=20,proficiency=4})

--ADD DDG 96 BAINBRIDGE AND 2 x Lynx (one of the 8 ship around George Bush)
local u = ScenEdit_AddUnit({type='Ship', name='Bainbridge', heading =0, speed=20, dbid =2873, side ='USA', heading =0, speed=0, altitude=0, proficiency=4, latitude=90.0000, longitude=135.0000})

local point = ScenEdit_AddReferencePoint({side='USA',name='Unit Placeholder2',RelativeTo='George Bush', bearing=315, distance=7})
ScenEdit_DeleteReferencePoint({name='Unit Placeholder2', side='USA'})
u.latitude = point.latitude
u.longitude = point.longitude

for x = 1, 2, 1 do
local name = 'Knighthawk 21-'..math.random(100,999)
local proficiency = math.random(2,3)+1
ScenEdit_AddUnit({type='Aircraft', side='USA', name=name, dbid =5337, loadoutid =13430, base='Bainbridge', AddUnit='DDG'})

end
User avatar
michaelm75au
Posts: 12455
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

Re: Carrier Strike Group

Post by michaelm75au »

Here is the use of the formation method I was referring to.
Note that the 'transpose' option is not in the latest build - it was missing. Currently it would place the formation marker but the ship would move there. Once the 'transpose' option is in place, it will teleport to the location.

Code: Select all

--CVN 77 GEORGE BUSH - (mothership)
ScenEdit_AddUnit({type='Ship', name='George Bush', heading =0, dbid =3225, side ='blue', Latitude='N69.00.00',Longitude='E10.00.00', altitude='0 ft', speed=20,proficiency=4, group = "CVN TG"})

--ADD DDG 96 BAINBRIDGE AND 2 x Lynx (one of the 8 ship around George Bush)
local u = ScenEdit_AddUnit({type='Ship', name='Bainbridge', heading =0, speed=20, dbid =2873, side ='blue', heading =0, speed=0, altitude=0, proficiency=4, Latitude='N69.00.00',Longitude='E10.00.00', group = "CVN TG"})

u.formation = {type='rotating', bearing=315, distance=7, transpose=true} -- station = relative bearing 315 deg at 7 NM from lead
Michael
Zyph
Posts: 37
Joined: Mon Sep 12, 2022 6:58 pm

Re: Carrier Strike Group

Post by Zyph »

michaelm75au wrote: Sat Mar 25, 2023 12:55 am Here is the use of the formation method I was referring to.
Note that the 'transpose' option is not in the latest build - it was missing. Currently it would place the formation marker but the ship would move there. Once the 'transpose' option is in place, it will teleport to the location.

Code: Select all

--CVN 77 GEORGE BUSH - (mothership)
ScenEdit_AddUnit({type='Ship', name='George Bush', heading =0, dbid =3225, side ='blue', Latitude='N69.00.00',Longitude='E10.00.00', altitude='0 ft', speed=20,proficiency=4, group = "CVN TG"})

--ADD DDG 96 BAINBRIDGE AND 2 x Lynx (one of the 8 ship around George Bush)
local u = ScenEdit_AddUnit({type='Ship', name='Bainbridge', heading =0, speed=20, dbid =2873, side ='blue', heading =0, speed=0, altitude=0, proficiency=4, Latitude='N69.00.00',Longitude='E10.00.00', group = "CVN TG"})

u.formation = {type='rotating', bearing=315, distance=7, transpose=true} -- station = relative bearing 315 deg at 7 NM from lead
Naah i see that you use lat and lon for bainbridge, that is what i trying to avoid. I want a code so i just need to change the carriers coordinates and all the ships will move to location relativeTo the carrier.
User avatar
blu3s
Posts: 637
Joined: Fri Jul 08, 2022 9:45 am

Re: Carrier Strike Group

Post by blu3s »

Zyph wrote: Sat Mar 25, 2023 8:51 am
Naah i see that you use lat and lon for bainbridge, that is what i trying to avoid. I want a code so i just need to change the carriers coordinates and all the ships will move to location relativeTo the carrier.

Use the carrier latitude,longitude with the method GetPointFromBearing to get the latitude/longitude of the other ships
Zyph
Posts: 37
Joined: Mon Sep 12, 2022 6:58 pm

Re: Carrier Strike Group

Post by Zyph »

blu3s wrote: Sat Mar 25, 2023 9:31 am
Zyph wrote: Sat Mar 25, 2023 8:51 am
Naah i see that you use lat and lon for bainbridge, that is what i trying to avoid. I want a code so i just need to change the carriers coordinates and all the ships will move to location relativeTo the carrier.

Use the carrier latitude,longitude with the method GetPointFromBearing to get the latitude/longitude of the other ships
I did with this code, don't know how clean it is but it works:))

--CVN 77 GEORGE BUSH - (mothership)
ScenEdit_AddUnit({type='Ship', name='George Bush', heading =0, dbid =3225, side ='USA', Latitude='N69.00.00',Longitude='E10.00.00', altitude='0 ft', speed=20,proficiency=4})

--ADD DDG 96 BAINBRIDGE AND 2 x Lynx (one of the 8 ship around George Bush)
local u = ScenEdit_AddUnit({type='Ship', name='Bainbridge', heading =0, speed=20, dbid =2873, side ='USA', heading =0, speed=0, altitude=0, proficiency=4, latitude=90.0000, longitude=135.0000})

local point = ScenEdit_AddReferencePoint({side='USA',name='Unit Placeholder2',RelativeTo='George Bush', bearing=315, distance=7})
ScenEdit_DeleteReferencePoint({name='Unit Placeholder2', side='USA'})
u.latitude = point.latitude
u.longitude = point.longitude

for x = 1, 2, 1 do
local name = 'Knighthawk 21-'..math.random(100,999)
local proficiency = math.random(2,3)+1
ScenEdit_AddUnit({type='Aircraft', side='USA', name=name, dbid =5337, loadoutid =13430, base='Bainbridge', AddUnit='DDG'})

end
Top
User avatar
blu3s
Posts: 637
Joined: Fri Jul 08, 2022 9:45 am

Re: Carrier Strike Group

Post by blu3s »

Zyph wrote: Sat Mar 25, 2023 12:38 pm I did with this code, don't know how clean it is but it works:))

--CVN 77 GEORGE BUSH - (mothership)
local cv = ScenEdit_AddUnit({type='Ship', name='George Bush', heading =0, dbid =3225, side ='USA', Latitude='N69.00.00',Longitude='E10.00.00', altitude='0 ft', speed=20,proficiency=4})

--ADD DDG 96 BAINBRIDGE AND 2 x Lynx (one of the 8 ship around George Bush)
local ddg_pos = World_GetPointFromBearing( { latitude = cv.latitude, longitude = cv.longitude,
distance = 7, bearing = 315} )
local u = ScenEdit_AddUnit({type='Ship', name='Bainbridge', heading =0, speed=20, dbid =2873, side ='USA', speed=0, proficiency=4, latitude=ddg_pos.latitude, longitude=ddg_pos.longitude})

...
You don't need to create a RP. You store your carrier in a variable an with GetPointFromBearing you can get the ddg position with your cv position, bearing and distance as desired. Hope it helps
Zyph
Posts: 37
Joined: Mon Sep 12, 2022 6:58 pm

Re: Carrier Strike Group

Post by Zyph »

blu3s wrote: Sat Mar 25, 2023 2:43 pm
Zyph wrote: Sat Mar 25, 2023 12:38 pm I did with this code, don't know how clean it is but it works:))

--CVN 77 GEORGE BUSH - (mothership)
local cv = ScenEdit_AddUnit({type='Ship', name='George Bush', heading =0, dbid =3225, side ='USA', Latitude='N69.00.00',Longitude='E10.00.00', altitude='0 ft', speed=20,proficiency=4})

--ADD DDG 96 BAINBRIDGE AND 2 x Lynx (one of the 8 ship around George Bush)
local ddg_pos = World_GetPointFromBearing( { latitude = cv.latitude, longitude = cv.longitude,
distance = 7, bearing = 315} )
local u = ScenEdit_AddUnit({type='Ship', name='Bainbridge', heading =0, speed=20, dbid =2873, side ='USA', speed=0, proficiency=4, latitude=ddg_pos.latitude, longitude=ddg_pos.longitude})

...
You don't need to create a RP. You store your carrier in a variable an with GetPointFromBearing you can get the ddg position with your cv position, bearing and distance as desired. Hope it helps
Very nice! Thank you, have a nice evening!
User avatar
michaelm75au
Posts: 12455
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

Re: Carrier Strike Group

Post by michaelm75au »

michaelm75au wrote: Sat Mar 25, 2023 12:55 am Here is the use of the formation method I was referring to.
Note that the 'transpose' option is not in the latest build - it was missing. Currently it would place the formation marker but the ship would move there. Once the 'transpose' option is in place, it will teleport to the location.

Code: Select all

--CVN 77 GEORGE BUSH - (mothership)
ScenEdit_AddUnit({type='Ship', name='George Bush', heading =0, dbid =3225, side ='blue', Latitude='N69.00.00',Longitude='E10.00.00', altitude='0 ft', speed=20,proficiency=4, group = "CVN TG"})

--ADD DDG 96 BAINBRIDGE AND 2 x Lynx (one of the 8 ship around George Bush)
local u = ScenEdit_AddUnit({type='Ship', name='Bainbridge', heading =0, speed=20, dbid =2873, side ='blue', heading =0, speed=0, altitude=0, proficiency=4, Latitude='N69.00.00',Longitude='E10.00.00', group = "CVN TG"})

u.formation = {type='rotating', bearing=315, distance=7, transpose=true} -- station = relative bearing 315 deg at 7 NM from lead
In order to add a ship, you need to give it a location. I gave it the same location as the CVN, and then set the formation information for each ship. This would then reposition the ship.
Michael
Post Reply

Return to “Lua Legion”