Adding units

Post new mods and scenarios here.

Moderator: MOD_Command

Post Reply
Chris21wen
Posts: 6975
Joined: Thu Jan 17, 2002 10:00 am
Location: Cottesmore, Rutland

Adding units

Post by Chris21wen »

It seems that when you add a unit to the map it always points north or it has done so so far. Is there anyway to orientate them differently?
lamboman43
Posts: 96
Joined: Thu Apr 14, 2016 10:38 pm

RE: Adding units

Post by lamboman43 »

As far as I can tell, unfortunately, you can ONLY do it for facility units and you have to do each one individually after placement. To do so right click on the unit, go down to scenario editor at the very bottom and then click set orientation. Then drag the slider to the desired orientation. Another (slower IMO) way is to click the unit, go up to the editor tab at the top of the window and click unit actions, and then click set orientation.

Hope those messy instructions make sense :P
Chris21wen
Posts: 6975
Joined: Thu Jan 17, 2002 10:00 am
Location: Cottesmore, Rutland

RE: Adding units

Post by Chris21wen »

ORIGINAL: lamboman43

As far as I can tell, unfortunately, you can ONLY do it for facility units and you have to do each one individually after placement. To do so right click on the unit, go down to scenario editor at the very bottom and then click set orientation. Then drag the slider to the desired orientation. Another (slower IMO) way is to click the unit, go up to the editor tab at the top of the window and click unit actions, and then click set orientation.

Hope those messy instructions make sense :P

Thanks
User avatar
Gunner98
Posts: 5881
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: Adding units

Post by Gunner98 »

There are a couple ways you can fix this: Add the unit via a Lua command in the script counsel with the desired heading.

Or the old fashioned way. Add the unit in a blank scenario, give it orders to head in whatever direction, run the game - stop time and export when it is pointing the right way. Then import it.

B
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
Chris21wen
Posts: 6975
Joined: Thu Jan 17, 2002 10:00 am
Location: Cottesmore, Rutland

RE: Adding units

Post by Chris21wen »

ORIGINAL: Gunner98

There are a couple ways you can fix this: Add the unit via a Lua command in the script counsel with the desired heading.

If I knew what that was I might.
ORIGINAL: Gunner98
Or the old fashioned way. Add the unit in a blank scenario, give it orders to head in whatever direction, run the game - stop time and export when it is pointing the right way. Then import it.

B

Would that work with a group?
User avatar
Gunner98
Posts: 5881
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: Adding units

Post by Gunner98 »

The Lua method:

ScenEdit_AddUnit({type='Ship', side='NATO Support', name='AOE 6 Supply', dbid='490', heading='240', latitude='55.3474463444513', longitude='-35.1083051655598'})

Just change up everything inside the '..' to what you need. You can get the Lat/Long by clicking your mouse on the map where you want it - leave the pointer there and use the hotkey 'Ctrl x', it is now in your computers clipboard and you can paste it.

Go to the Script counsel (bottom of the Edit menu) put the code in the bottom box and hit 'Run' (not able to access the game at the moment, so I may have things mixed up). This is meant to test script, and it will, but it will put the unit where you want it.

The other method will work for groups. The Q&A at the link is about fuel level but the same process applies to unit headings

http://qa.commandmodernairnavaloperatio ... how=65#q65

Hope that helps

B
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
Chris21wen
Posts: 6975
Joined: Thu Jan 17, 2002 10:00 am
Location: Cottesmore, Rutland

RE: Adding units

Post by Chris21wen »

I posted originally because it was grouped units in a TF that was caused the problem. Found another way to deal with it, if the unit has a relative station set it for it's current direction i.e. north; but roughly manual position it for it's desired direction of travel. For fixed stations set both for the direction of intended travel. The only waiting time involved now is time taken by the lead ship to do the turn.
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

RE: Adding units

Post by butch4343 »

Gunner,

I wondered if I could query something related, is there a way to add two surface warships to a scenario then group them into one TF?

So heres my scenario , I have three patrol boxes and for playabilty I would like on scenario load, the units to be placed in a random fashion in a patrol box, I have this first part nailed fine with the random seed script.

I assign a unit , give it a name ect and assign it to an ASW patrol for that box

It works fine for a single Sub or Warship

My issue is this , I have a group of two ships , lets call them TF84, I can do the assign each unit individually, my question is how do I group them into TF 84, if this is possible?

It would be good if there was a LUA function, Scen_Edit-PlaceUnit{Unitname,Lat,Long} alas I cant fin anything like that at the moment.

Kind Regards

Butch
User avatar
Gunner98
Posts: 5881
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: Adding units

Post by Gunner98 »

Butch

I don't think I've ever done that but this should work:

ScenEdit_SetUnit({side="your side", unitname="your unit", group="TF84"})

Have not tested but I think it should work.

B
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

RE: Adding units

Post by butch4343 »

ORIGINAL: Gunner98

Butch

I don't think I've ever done that but this should work:

ScenEdit_SetUnit({side="your side", unitname="your unit", group="TF84"})

Have not tested but I think it should work.

B



Hey Gunner


Thanks for the script mate, I gave it whirl last night and didnt get too far. I tried

math.randomseed( os.time() )

a = math.random(1,10)

if a<5 then

ScenEdit_AddUnit({side='NATO Naval', type='Ship', name='USS Samson', dbid=2058, latitude='66.1583775408430', longitude='-23.8887196452772'})
ScenEdit_AddUnit({side='NATO Naval', type='Ship', name='HMCS Huron', dbid=202, latitude='66.1583775408429', longitude='-23.8887196452772'})
ScenEdit_AddUnit({side='NATO Naval', type='Ship', name='USS Badger', dbid=2668, latitude='66.1583775408428', longitude='-23.8887196452772'})
ScenEdit_AssignUnitToMission('USS Samson','Yellow Patrol')
ScenEdit_AssignUnitToMission('HMCS Huron','Yellow Patrol')
ScenEdit_AssignUnitToMission('USS Badger','Yellow Patrol')
ScenEdit_SetUnit({side='NATO Naval', unitname='USS Samson', group='TF84'})
ScenEdit_SetUnit({side='NATO Naval', unitname='HMCS Huron', group='TF84'})
ScenEdit_SetUnit({side='NATO Naval', unitname='USS Badger', group='TF84'})




elseif a>=5 and a<8 then

ScenEdit_AddUnit({side='NATO Naval', type='Ship', name='USS Samson', dbid=2058, latitude='68.3860814725077', longitude='-20.6965220128941'})
ScenEdit_AddUnit({side='NATO Naval', type='Ship', name='HMCS Huron', dbid=202, latitude='68.3760814725070', longitude='-20.6965220128941'})
ScenEdit_AddUnit({side='NATO Naval', type='Ship', name='USS Badger', dbid=2668, latitude='68.3960814725063', longitude='-20.6965220128941'})
ScenEdit_AssignUnitToMission('USS Samson','Red Patrol')
ScenEdit_AssignUnitToMission('HMCS Huron','Red Patrol')
ScenEdit_AssignUnitToMission('USS Badger','Red Patrol')
ScenEdit_SetUnit({side='NATO Naval', unitname='USS Samson', group='TF84'})
ScenEdit_SetUnit({side='NATO Naval', unitname='HMCS Huron', group='TF84'})
ScenEdit_SetUnit({side='NATO Naval', unitname='USS Badger', group='TF84'})

elseif a>=8 then

ScenEdit_AddUnit({side='NATO Naval', type='Ship', name='USS Samson', dbid=2058, latitude='69.9172187735236', longitude='-18.4004764948711'})
ScenEdit_AddUnit({side='NATO Naval', type='Ship', name='HMCS Huron', dbid=202, latitude='69.9072187735246', longitude='-18.4004764948711'})
ScenEdit_AddUnit({side='NATO Naval', type='Ship', name='USS Badger', dbid=2668, latitude='69.9272187735266', longitude='-18.4004764948711'})
ScenEdit_AssignUnitToMission('USS Samson','Orange Patrol')
ScenEdit_AssignUnitToMission('HMCS Huron','Orange Patrol')
ScenEdit_AssignUnitToMission('USS Badger','Orange Patrol')
ScenEdit_SetUnit({side='NATO Naval', unitname='USS Samson', group='TF84'})
ScenEdit_SetUnit({side='NATO Naval', unitname='HMCS Huron', group='TF84'})
ScenEdit_SetUnit({side='NATO Naval', unitname='USS Badger', group='TF84'})


end

And the result is that I place the units of TF84 at a random location but they dont group together. I was thinking just last night though since its the ASW aspect to the mission , I could just get away with using single units as opposed to a group.

I did try a simpler second script to test it

ScenEdit_SetUnit({side="NATO", unitname="1", group="TF84"})
ScenEdit_SetUnit({side="NATO", unitname="2", group="TF84"})

Still no joy lol

Anyways Ive included it below if it helps.

Thanks for your help though mate.

Regards

Butch

Attachments
21.TheLo..GUIKGap.zip
(56.21 KiB) Downloaded 13 times
Rory Noonan
Posts: 2418
Joined: Thu Dec 18, 2014 1:53 am
Location: Brooklyn, NY

RE: Adding units

Post by Rory Noonan »

Hey butch,

I had a tinker and couldn't get the game to add a new group via Lua;

In the documentation (https://commandlua.github.io/index.html#Unit) group creation is listed as being experimental. Maybe it's worth a tech support ticket or a feature request?

Nice looking scenario by the way, will definitely be playing that one when it comes out!
Image
angster
Posts: 89
Joined: Mon Oct 12, 2015 10:25 am

RE: Adding units

Post by angster »

Whelp, not perfect but maybe it will work for you

1.) Create a mock group manually, hide it somewhere
2.) Create your all you units
3.) Set mock group unit coordinates to the location you want
4.) Add all your created units, then delete the original mock group units

Attached an example
Attachments
Test.zip
(4.59 KiB) Downloaded 13 times
User avatar
michaelm75au
Posts: 12455
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Adding units

Post by michaelm75au »

There is a trick to this.[:D]
To use the 'group' in the SetUnit(), the group object needs to exist.
However, you can create the 'group' thru the unit wrapper.

local a = ScenEdit_AddUnit({side='NATO Naval', type='Ship', name='USS Samson', dbid=2058, latitude='68.3860814725077', longitude='-20.6965220128941'})
ScenEdit_AddUnit({side='NATO Naval', type='Ship', name='HMCS Huron', dbid=202, latitude='68.3760814725070', longitude='-20.6965220128941'})
ScenEdit_AddUnit({side='NATO Naval', type='Ship', name='USS Badger', dbid=2668, latitude='68.3960814725063', longitude='-20.6965220128941'})

a.group = 'TF84' -- creates the group object
ScenEdit_SetUnit({side='NATO Naval', unitname='HMCS Huron', group='TF84'})
ScenEdit_SetUnit({side='NATO Naval', unitname='USS Badger', group='TF84'})
Michael
thewood1
Posts: 9138
Joined: Sun Nov 27, 2005 6:24 pm
Location: Boston

RE: Adding units

Post by thewood1 »

That is very cool. I would never have thought of that.
Post Reply

Return to “Mods and Scenarios”