AI side: LST goes to port, unloads, units move to area

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
Whicker
Posts: 665
Joined: Tue Jun 19, 2018 9:54 pm

AI side: LST goes to port, unloads, units move to area

Post by Whicker »

I am trying to get an LST (#2801 T61 Capana) to go to a port, unload its cargo and then have those units move to a certain area, and maybe assign some of them to a mission.

I can do it manually at each step, but I can't see how to setup a cargo mission to do it as the LST is not a mothership. I can add the dock as the mothership, but there aren't any units to unload from the dock.

Any ideas on how to go about this? would it be easier to just teleport the units around once the ship arrives? or once the ship arrives have lua unload it (ScenEdit_UnloadCargo (fromUnit, cargoList)) and then what - it seems like when cargo unloads the units get bundled as different things than they were when they went in. Will I know what the unit guids/? are after they unload?

Note to self: if you can't figure out how to add cargo to a ship/other make sure you have the cargo option turned on in the game settings.
Whicker
Posts: 665
Joined: Tue Jun 19, 2018 9:54 pm

RE: AI side: LST goes to port, unloads, units move to area

Post by Whicker »

interesting - it looks like a ship with cargo unloads to the dock automatically? cool, step one sorted.

And it looks like you can set up a cargo mission with the LST to unload to an area if the pier is selected as its home base. The area has to be near the coast - the ship will travel over land to drop off stuff. Everything gets lumped together by type it seems - like all Inf gets put together in one big unit, with multiple different unit types all on top of each other rather than spread out in the area defined.

Using lua I can unload stuff once the ship unloads on the pier, and here I can control how many units in a group, just have to know the dbids of the stuff in the cargo.

ScenEdit_UnloadCargo('af22e48c-256d-48d7-bc22-0fb630e0e889', { {2,2380}})

now to figure out how to get them to move to where I want them, I can sort of tell the unit name as it is Inf #10X or Mech Inf #10X.
Whicker
Posts: 665
Joined: Tue Jun 19, 2018 9:54 pm

RE: AI side: LST goes to port, unloads, units move to area

Post by Whicker »

as long as you know the unit name then setting the course is easy - assuming you know the lat/long:

local a =ScenEdit_GetUnit({ unitname='Mech Inf #105'})
a.course = {{ lat =a.latitude, lon=a.longitude}, {lat=19.3874718855336, lon=-81.3869183989322} }
print (a.course)

If there are less than a dozen things to set I suppose this isn't too bad. Hardest part is going to be keeping the unit names correct, as I don't see how to control it. Maybe a trigger with unit enters area and then using UnitX would work.

Tried it with a trigger on enters area and it doesn't work, cause you either have the area include the pier which throws an error (pier can't have a course) or if the area is right next to the pier the units unload but are directly on the pier so they don't hit the area.
Post Reply

Return to “Lua Legion”