infantry drop (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion



Message


wqc12345 -> infantry drop (6/9/2020 3:32:34 PM)

I'm trying to drop an infantry unit (from edit cargo). The manual process works, where I add a infantry section, select unload cargo and the unit appears.

If I script it, I get an Object reference not set to an instance of an object error.

local u = SE_GetUnit({name='Cub4', guid='RHR5WE-0HM0B0J6KFMOU'})
print(u.cargo[1].cargo)
for k,v in pairs (u.cargo[1].cargo) do
print(v.dbid)
ScenEdit_UnloadCargo(u.guid, { {v.quantity,v.dbid}})
end

{ [1] = { mass = 0, status = 'Operational', name = 'Spetsnaz Saboteur', area = 0, dbid = 880, crew = 1, quantity = 10, guid = 'RHR5WE-0HM0CJQSARNTP' } }
880
ERROR: Object reference not set to an instance of an object.

I'm using arrays, since I'll have several planes in the section, but even if I'm explicit in my reference parameters, meaning, CUB1, it still returns an error?

This is definitely a bug.. needs fixing. Because it works manually.

I've tried everything and there doesn't seem to be a way to unload cargo from a aircraft. You can certainly do it manually, but the ID field doesn't seem to conform to the dbid field in the database. Anyway, any help here would be greatly appreciated. Also, adding cargo to a guid doesn't seem to work, and not sure why?

am I missing something




KnightHawk75 -> RE: infantry drop (6/9/2020 10:08:06 PM)

I'll take a look, as for the scene setup, all I need is a paratroop loadout plane (or group of them) with 10 sabo's loaded as cargo in each them to duplicate the basic circumstances right? I ask cause I've found cargo setups to be very particular, is there a particular unit# I should use to simulate the above. Also the 880 dbid there seems odd should be 858 for a Spetsnaz Saboteur mount, or 1944\1946 for a Spetsnaz sabo facility. hmm.







wqc12345 -> RE: infantry drop (6/9/2020 10:18:42 PM)

Hi KnightHawk,

Thanks for taking the time to take a look. Yes, I have manually executed the order with the ID of the cargo. Meaning, I've taken an AN-12 Cub, loaded it with 10 Spezsnaz ID: 880 units and "unloaded" the cargo manually and they drop.

I do the same thing with code, meaning, I just run the below code (and I tested it against a port land structure with the same cargo) and it worked, but it didn't work with the AN-12.

[img]https://i.ibb.co/Q88Q6hD/cargo.png[/img]

See above for the image in cargo that references the unit.

Here is the cargo displayed

[img]https://i.ibb.co/Qd6cHsL/Untitled.png[/img]

I've attached the images in case the images don't show




KnightHawk75 -> RE: infantry drop (6/10/2020 5:35:24 AM)

Weird on the db#'s maybe different ones are enabled in db485, or maybe you're using CWDB?.
[img]https://i.postimg.cc/zyq2FcK0/DB485-AN12-BP-Cuba.jpg[/img]
Anyway...


Ok so I went digging. I found three things.

First yup it's broke, it doesn't matter what you feed it when it's an aircraft.
The part where it dies is after it's found or not found the stuff we send it. Doesn't matter if you feed it guids or {num,dbids} sets or really if it finds any matches or not. It'll die when it gets to a point of code after building it's cargo list that looks something like this [for devs eyes]
...
if(activeUnit is Aircraft)  //it is valid and aircraft...so next line fires and then throws object not set.
{   
if (((Aircraft_AirOps)activeUnit2.\SomeObsfucatedFunctionOrProperty()).\SomeOtherObsfucatedFunctionOrProperty())
...

I can confirm activeUnit2 is indeed null when it reaches there and whatever the above it meant to do to maybe change that doesn't happen.


Second thing that I noticed during this and maybe one of the devs can confirm or not is that while the {{5,851}...} type parameter works as expected the guid {'guidhere,guidhere'} one does not. It parses the list fine, but it seems to do a compare on each individual cargo entries mount guid vs some overall package\group guid we see in unit.cargo entries.

So for example (in the attached scene) I added 10 #851's and 10 #858's to a IL76MD-90A with a 50ton air-drop loadout, one of those has paradrop capability flagged one of them doesn't (I wanted to see if it would let me drop it anyway).

The print(u.cargo) produces
{ [1] = { name = 'Ace Tomato #1', cargo = { [1] = { crew = 1, guid = '4FH7PU-0HM0CDR2UPE6Q', area = 0, mass = 0, quantity = 10, name = 'Spetsnaz Saboteur', dbid = 858, status = 'Operational' }, [2] = { crew = 1, guid = '4FH7PU-0HM0CDR2UPE82', area = 0, mass = 0, quantity = 10, name = 'SpecOp Saboteur', dbid = 851, status = 'Operational' } }, guid = '4FH7PU-0HM0CDR2UPE4G' } }

I assumed I could pass it those two guids to bulk drop them all but, that's not what think I saw happening, I saw it do a comparison between 0-19 individual cargo entries each having their own guid, of which of course none matched. When I recorded what some of those were such as 4FH7PU-0HM0CDR2UPE81 and 4FH7PU-0HM0CDR2UPE61, and ran it again, then I saw it match and get added to the drop list. Now btw that's cool we can specify specific dudes to drop, but the issue is how do we get the full list of those guids to know to do that?


Third thing is, it does work for Ships. Sort of.
That is the {num,dbid} process does complete without errors for ships. However unlike in gui, there doesn't seem to be a check for near-by land and placement there, it will drop the units into the ocean. So that that's a little bit of a problem. I suppose the guid works too for ships but I didn't want to go through another debug session to find out the individual ones for ones I stuck on a carrier in the scene. Another issue is that when you feed it a guid that didn't do anything it returns true anyway as if it did something. idk I think it should return false that no match was found.

attch: TestRig_CargoOps_TroopDrop2.scen (play red, special actions help demo problems...ignore blue side)

Edit - Side note: When triggering unload via the gui on Ace Tomato #1, it drops the paradrop flagged guys, the other 10 that are not capable just deleted, which strikes me as odd, I guess they just get thrown out the back without chutes. [:D]












michaelm75au -> RE: infantry drop (6/10/2020 9:00:25 AM)

Yes, sorry my mistake.
I used 'unitTO' rather than 'unitFROM' to test if the aircraft was on the ground. And of cause as 'unitTO' doesn't exist ....




michaelm75au -> RE: infantry drop (6/10/2020 9:16:13 AM)

The {dbid,dbid,dbid,..} does work in the Lua function, but not for para-drops. It uses the same base function as the UI, so all para-drop capable mounts are created as a unit, and the cargo cleared.

The UI function won't drop the cargo unless all the cargo mounts are drop capable. If you have a case where this is wrong, please drop in a save to see what defect exists.

Looking at this, I think I can see the issue. Will let you know if I need a save.




michaelm75au -> RE: infantry drop (6/10/2020 10:29:36 AM)

Logged 0013942




wqc12345 -> RE: infantry drop (6/10/2020 3:04:58 PM)

Hey, thanks a lot Michael. Appreiciate the digging and bug report.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.7070313