Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Adding aircraft to a ship or airfield?

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Adding aircraft to a ship or airfield? Page: [1]
Login
Message << Older Topic   Newer Topic >>
Adding aircraft to a ship or airfield? - 5/25/2020 8:00:00 PM   
ProdigyofMilitaryPride

 

Posts: 86
Joined: 4/17/2015
Status: offline
As I'm crafting a scenario involving a Carrier Strike Group in '93 appearing via LUA, how do I add the aircraft to the carrier itself and its escorts? Thanks. You can link me up to another thread if need-be.

_____________________________

"The courageous must protect freedom." - Dwight D. Eisenhower
"Anything built by human hands can be destroyed. This is no exception." - Kei "Edge" Nagase, Ace Combat 5: The Unsung War
Post #: 1
RE: Adding aircraft to a ship or airfield? - 5/26/2020 3:55:55 AM   
ProdigyofMilitaryPride

 

Posts: 86
Joined: 4/17/2015
Status: offline
And a little more elaboration - I'm wanting to add these aircraft to the carrier and its escorts amid a script in which a group is being created. If you've got the advice for me, shoot a reply, please.

_____________________________

"The courageous must protect freedom." - Dwight D. Eisenhower
"Anything built by human hands can be destroyed. This is no exception." - Kei "Edge" Nagase, Ace Combat 5: The Unsung War

(in reply to ProdigyofMilitaryPride)
Post #: 2
RE: Adding aircraft to a ship or airfield? - 5/26/2020 5:15:23 AM   
KnightHawk75

 

Posts: 591
Joined: 11/15/2018
Status: offline
Cool, that should be no problem.

Here is a recent example I posted for doing it either as you create the unit, or after the fact:
https://www.matrixgames.com/forums/tm.asp?m=4803975#

I'll repaste it here with one minor tweek, the original used c.guid, and seems must be c.name;
and I added a line that assigns the group name to the Ship after it's generated.
local c, u,retval;
c = ScenEdit_AddUnit({type = 'Ship', name = 'MyCarrier', loadoutid = 0,
    heading = 0, dbid = 2370, side = 'Blue', Latitude="S4.50.00",Longitude="W5.00.00",
    autodetectable="false",holdfire="true",proficiency=4,speed=0});
c.group = 'MyCarrierGroup';
u = ScenEdit_AddUnit({type = 'Aircraft', name = 'F-35 single', loadoutid = 10098,
    heading = 0, dbid = 824, side = 'Blue', Latitude="N00.50.00",Longitude="E0.50.00",
    altitude="0 ft",autodetectable="false",holdfire="true",proficiency=4,speed=350,
    base=c.name}); -- <<--- base= parameter

--or exclude base= parameters above in unit creation and after creation use..
--retval = ScenEdit_HostUnitToParent({HostedUnitNameOrID=u.guid,SelectedHostNameOrID=c.guid})
--if retval == true then print(string.format('Successfully inserted %s into %s',u.name,c.name)); end
c=nil;u=nil;retval=nil;
You can duplicate 'c' lines all you want for each ship you want.. same for u and aircraft. Or if many are the same you can use a for loop to save you some paste and changing if many are the same ship type.

Example of the above but adding 12 of the same f-35's to the carrier named 'Knightrider #1 -#12':
local c, u,retval;
c = ScenEdit_AddUnit({type = 'Ship', name = 'MyCarrier', loadoutid = 0,
    heading = 0, dbid = 2370, side = 'Blue', Latitude="S4.50.00",Longitude="W5.00.00",
    autodetectable="false",holdfire="true",proficiency=4,speed=0});
c.group = 'MyCarrierGroup';
for i=1,12 do
u = ScenEdit_AddUnit({type = 'Aircraft', name = 'KnightRider #' .. i, loadoutid = 10098,
    heading = 0, dbid = 824, side = 'Blue', Latitude="N00.50.00",Longitude="E0.50.00",
    altitude="0 ft",autodetectable="false",holdfire="true",proficiency=4,speed=350,
    base=c.name}); -- <<--- base= parameter

--or exclude base= parameters above in unit creation and after creation use..
--retval = ScenEdit_HostUnitToParent({HostedUnitNameOrID=u.guid,SelectedHostNameOrID=c.guid})
--if retval == true then print(string.format('Successfully inserted %s into %s',u.name,c.name)); end
end
c=nil;u=nil;retval=nil;
Let me know if you still have questions or are unsure of how to attempt something or what a line means\does.

< Message edited by KnightHawk75 -- 5/26/2020 5:26:11 AM >

(in reply to ProdigyofMilitaryPride)
Post #: 3
RE: Adding aircraft to a ship or airfield? - 6/6/2020 5:45:27 AM   
ProdigyofMilitaryPride

 

Posts: 86
Joined: 4/17/2015
Status: offline
I found out there was meant to be a matching element, what am I missing here?
quote:

>> local c, u,retval;
c = ScenEdit_AddUnit({type = 'Ship', name = 'MyCarrier', loadoutid = 0,
heading = 0, dbid = 2370, side = 'Blue', Latitude="S4.50.00",Longitude="W5.00.00",
autodetectable="false",holdfire="true",proficiency=4,speed=0});
c.group = 'MyCarrierGroup';
u = ScenEdit_AddUnit({type = 'Aircraft', name = 'F-35 single', loadoutid = 10098,
heading = 0, dbid = 824, side = 'Blue', Latitude="N00.50.00",Longitude="E0.50.00",
altitude="0 ft",autodetectable="false",holdfire="true",proficiency=4,speed=350,
base=c.name}); -- <<--- base= parameter

--or exclude base= parameters above in unit creation and after creation use..
--retval = ScenEdit_HostUnitToParent({HostedUnitNameOrID=u.guid,SelectedHostNameOrID=c.guid})
--if retval == true then print(string.format('Successfully inserted %s into %s',u.name,c.name)); end
c=nil;u=nil;retval=nil;
ERROR: Sequence contains no matching element


And in trying to craft the code so far for a scenario I'm making, I keep getting a Syntax error by the ", proficiency=4, speed=350, basename=USS George Washington});.

quote:

local c, u retval;
c = ScenEdit_AddUnit({type = 'Ship', name = 'USS George Washington', heading = 85, dbid = 657, side = 'USN', Latitude = "N32.51.55", Longitude = "W13.43.21", autodetectable="false",holdfire="false",proficiency=4,speed=20});
c.group='George Washington CSG';
u = ScenEdit_AddUnit({type = 'Aircraft', name = "Dog", loadoutid = 17020, heading = 85, dbid = 46, side = 'USN', Latitude='N32.51.55', Longitude = "W13.43.21', autodetectable='false',holdfire="false", proficiency=4, speed=350, basename=USS George Washington});
c = ScenEdit_AddUnit({type = 'Ship', name = 'USS Thomas S. Gates', heading = 85, dbid = 1054, side = 'USN', Latitude = "32.51.55", Longitude = "W13.43.21", autodetectable="false",holdfire="false",proficiency=4,speed=20});
c.group='George Washington CSG'
c = ScenEdit_AddUnit({type = 'Ship', name = 'USS San Jacinto', heading = 85, dbid = 628, side = 'USN', Latitude = "32.51.55", Longitude = "W13.43.21", autodetectable="false",holdfire="false",proficiency=4,speed=20});
c.group='George Washington CSG'
c = ScenEdit_AddUnit({type = 'Ship', name = 'USS Barry', heading = 85, dbid = 112, side = 'USN', Latitude = "32.51.55", Longitude = "W13.43.21", autodetectable="false",holdfire="false",proficiency=4,speed=20});
u.group='George Washington CSG'
c = ScenEdit_AddUnit({type = 'Ship', name = 'USS Deyo', heading = 85, dbid = 810, side = 'USN', Latitude = "32.51.55", Longitude = "W13.43.21", autodetectable="false",holdfire="false",proficiency=4,speed=20});

--or exclude base= parameters above in unit creation and after creation use..
--retval = ScenEdit_HostUnitToParent({HostedUnitNameOrID=u.guid,SelectedHostNameOrID=c.guid})
--if retval == true then print(string.format('Successfully inserted %s into %s',u.name,c.name)); end
c=nil;u=nil;retval=nil;



_____________________________

"The courageous must protect freedom." - Dwight D. Eisenhower
"Anything built by human hands can be destroyed. This is no exception." - Kei "Edge" Nagase, Ace Combat 5: The Unsung War

(in reply to KnightHawk75)
Post #: 4
RE: Adding aircraft to a ship or airfield? - 6/6/2020 7:38:38 AM   
KnightHawk75

 

Posts: 591
Joined: 11/15/2018
Status: offline
Second section - you're are missing a comma in the line local c,u,<-- retval

Also on the line:
u = ScenEdit_AddUnit({type = 'Aircraft', name = "Dog", loadoutid = 17020, heading = 85, dbid = 46, side = 'USN', Latitude='N32.51.55', Longitude = "W13.43.21', autodetectable=false,holdfire="false", proficiency=4, speed=350, basename=USS George Washington});

-You have Longitude opened with a " and closed with a ' , you can use one or the other type not mix and match
-You have the string USS George Washinton without quotes around it.
-You specify basename= when it should just be base=
-You specified to create and aircraft but didn't specify a Altitude, which is required even if basing it.

Also you are missing the 'N' in lat's in many places.

Here is the corrected version of what you posted that runs without issue.
local u,c;
local grpName = 'George Washington CSG' 
c = ScenEdit_AddUnit({type = 'Ship', name = 'USS George Washington', heading = 85, dbid = 657, side = 'USN',
 Latitude = "N32.51.55", Longitude = "W13.43.21", autodetectable="false",holdfire="false",proficiency=4,speed=20});
c.group=grpName;
u = ScenEdit_AddUnit({type = 'Aircraft', name = "Dog", loadoutid = 17020, heading = 85, dbid = 46, side = 'USN',
 Latitude='N32.51.55', Longitude = 'W13.43.21', altitude=0,autodetectable="false",holdfire="false", proficiency=4, speed=350, base=c.name});
u = ScenEdit_AddUnit({type = 'Ship', name = 'USS Thomas S. Gates', heading = 85, dbid = 1054, side = 'USN', 
Latitude = "32.51.55", Longitude = "W13.43.21", autodetectable="false",holdfire="false",proficiency=4,speed=20});
u.group=grpName
u = ScenEdit_AddUnit({type = 'Ship', name = 'USS San Jacinto', heading = 85, dbid = 628, side = 'USN',
 Latitude = "N32.51.55", Longitude = "W13.43.21", autodetectable="false",holdfire="false",proficiency=4,speed=20});
u.group=grpName
u = ScenEdit_AddUnit({type = 'Ship', name = 'USS Barry', heading = 85, dbid = 112, side = 'USN',
 Latitude = "N32.51.55", Longitude = "W13.43.21", autodetectable="false",holdfire="false",proficiency=4,speed=20});
u.group=grpName
u = ScenEdit_AddUnit({type = 'Ship', name = 'USS Deyo', heading = 85, dbid = 810, side = 'USN',
 Latitude = "N32.51.55", Longitude = "W13.43.21", autodetectable="false",holdfire="false",proficiency=4,speed=20}); 
c,u = nil,nil;


On the first I get no such error about sequence.... when you run it do you actually have a Side called Blue?







< Message edited by KnightHawk75 -- 6/6/2020 7:47:44 AM >

(in reply to ProdigyofMilitaryPride)
Post #: 5
RE: Adding aircraft to a ship or airfield? - 6/6/2020 7:54:52 AM   
KnightHawk75

 

Posts: 591
Joined: 11/15/2018
Status: offline
So here is one that creates 6 tomcats on the washington, so you can use it as example for other aircraft you'll likely be doing.
local u,c;
local grpName = 'George Washington CSG' 
c = ScenEdit_AddUnit({type = 'Ship', name = 'USS George Washington', heading = 85, dbid = 657, side = 'USN',
 Latitude = "N32.51.55", Longitude = "W13.43.21", autodetectable="false",holdfire="false",proficiency=4,speed=20});
c.group=grpName;
for i=1,6 do
  u = ScenEdit_AddUnit({type = 'Aircraft', name = "Dog #" .. i, loadoutid = 17020, heading = 85, dbid = 46, side = 'USN',
 Latitude='N32.51.55', Longitude = 'W13.43.21', altitude=0,autodetectable="false",holdfire="false", proficiency=4, speed=350, base=c.name});
end
u = ScenEdit_AddUnit({type = 'Ship', name = 'USS Thomas S. Gates', heading = 85, dbid = 1054, side = 'USN',
 Latitude = "32.51.55", Longitude = "W13.43.21", autodetectable="false",holdfire="false",proficiency=4,speed=20});
u.group=grpName
u = ScenEdit_AddUnit({type = 'Ship', name = 'USS San Jacinto', heading = 85, dbid = 628, side = 'USN',
 Latitude = "N32.51.55", Longitude = "W13.43.21", autodetectable="false",holdfire="false",proficiency=4,speed=20});
u.group=grpName
u = ScenEdit_AddUnit({type = 'Ship', name = 'USS Barry', heading = 85, dbid = 112, side = 'USN',
 Latitude = "N32.51.55", Longitude = "W13.43.21", autodetectable="false",holdfire="false",proficiency=4,speed=20});
u.group=grpName
u = ScenEdit_AddUnit({type = 'Ship', name = 'USS Deyo', heading = 85, dbid = 810, side = 'USN',
 Latitude = "N32.51.55", Longitude = "W13.43.21", autodetectable="false",holdfire="false",proficiency=4,speed=20}); 
c,u = nil,nil;


< Message edited by KnightHawk75 -- 6/17/2020 2:43:07 PM >

(in reply to KnightHawk75)
Post #: 6
RE: Adding aircraft to a ship or airfield? - 6/17/2020 4:54:33 AM   
ProdigyofMilitaryPride

 

Posts: 86
Joined: 4/17/2015
Status: offline
And for adding additional magazine entries for carriers in carrying the appropriate weaponry for key missions.

_____________________________

"The courageous must protect freedom." - Dwight D. Eisenhower
"Anything built by human hands can be destroyed. This is no exception." - Kei "Edge" Nagase, Ace Combat 5: The Unsung War

(in reply to KnightHawk75)
Post #: 7
RE: Adding aircraft to a ship or airfield? - 6/17/2020 3:23:22 PM   
KnightHawk75

 

Posts: 591
Joined: 11/15/2018
Status: offline
quote:

ORIGINAL: ProdigyofMilitaryPride

And for adding additional magazine entries for carriers in carrying the appropriate weaponry for key missions.


For specifically adding Mags, I think you'll still have to resort to using a specific delta file for each specific unit guid involved there. I'm kind of glad you asked cause that's something I meaning to ask for that I totally forgot about, a AddMagazine(), or an addition to UpdateUnit() more likely with mode='add_mag','remove_mag', like we have for mounts.

Anyway for now to use the delta method. Customize the delta.ini file for you specific unit and then call UpdateUnit()

Let's assume for the example you have a delta file here: CMO-Install\Scenarios\KHTests\iniSaves\MyS400x12Default4.ini the contents are listed below
It does the following to a #2029 Facility.
Removes the original mag that has slower reload (lets cheat!)
Adds one that's near instantaneous, populate its with just 994 sa-21b's and no sa-21a records
Now delta files are a topic in and of themselves but this is just an example I had around, but most of all just make sure the <Unit_GUID-HERE> matches your unit or they will not get applied and throw an error.
<?xml version="1.0" encoding="utf-8"?>
<ScenarioUnits>
    <Unit_4FH7PU-0HM0IN9JP6C9D>
        <!--MyS400x12Default (SAM Bn (SA-21a/b Growler [S-400 Triumf]) [2029])-->
        <MagRemove_1_1363 />
        <!--SA-21a/b Bn-->
        <MagAdd_1185 />
        <!--Munitions-->
        <Mag_2_1185>
            <!--Munitions-->
            <WeaponRecAdd_0_2104 />
            <!--SA-21b Growler [40N6]-->
            <WeaponEdit_2104_994 />
            <!--SA-21b Growler [40N6]-->
        </Mag_2_1185>
    </Unit_4FH7PU-0HM0IN9JP6C9D>
</ScenarioUnits>
local unit = ScenEdit_GetUnit( { name='MyS400x12Default', guid='4FH7PU-0HM0IN9JP6C9D' } );
ScenEdit_UpdateUnit( {guid=unit.guid, name=unit.name, mode='delta', file='\\KHTests\\iniSaves\\MyS400x12Default4.ini'} ) ;

Now that actually does both,adds a mag and populates it with specific weapon records you want) but you could have just had the <MagAdd_1185 /> line to just add the mag and then used the following to throw stuff into the mags that exist (including the new ones you add):

ScenEdit_AddWeaponToUnitMagazine( {guid=unit.guid, wpn_dbid=2104, number=994, maxcap=10000,new=true} )
If there were 1000 in there already and you wanted to remove 500..
ScenEdit_AddWeaponToUnitMagazine( {guid=unit.guid, wpn_dbid=2104, number=500, remove=true} )

This assumes you don't care what goes in which mag, as I recall and I might be wrong it'll keep looking for
empty mags if it fills one up entirely and move on to the next. But test that cause I haven't in awhile.
When it comes to filling a mag you can either do it all like above and custom or if you're just looking for quick and easy way to say 'give me 25 loadouts for a f-22 with SBD's' into whatever mags are available then you can use:

ScenEdit_FillMagsForLoadout({guid=unit.guid, loadoutid=19337, quantity=25})
or if you were looping though a bunch of aircraft...
ScenEdit_FillMagsForLoadout({guid=unit.guid, loadoutid=u.loadoutdbid, quantity=25})


Now if you explicitly care about what weapons go into which specific mag inside the same unit, and there are multiple mags that share dbid id's like the generic 1185, well.. it can be done but it gets more involved. As you'll need to 'find' the matching mag-guid for it first, or you'll need to know the index in has in the mag table you want to put it in. Lot easier when you have stuff pre-made in the scenario, becomes more challenging as you try to add things like mags dynamically during a scenario where new guids and indexes might change but it can be done. I'll leave it there for now as doing the grab the specific mag-guid or by index etc is more and slightly more complex code, but if you need such it let me know.


(in reply to ProdigyofMilitaryPride)
Post #: 8
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Adding aircraft to a ship or airfield? Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.125