Jump to content

UnhookCargo Event? How do I detect unhooked cargo?


Recommended Posts

Posted

I feel slightly silly. So I wrote a mission where I dynamically spawn nice, juicy and beautiful cargo to transport across DCS world, and they show up nicely in the 'All Cargos' menu. I can pick them up with my Whirly and I felt great.

Until I came to the point where I wanted to program some kind of detection where and when said cargo was unhooked. I'm too stoopid, it seems, to find the correct event or condition for this. Now, I know that there probably is one, since in ME you can define a condition 'cargo unhooked in zone'. Since I'm working with dynamically spawned cargo, I can't use that condition. 

Does anyone know how I can synthesize such an event from the existing ones, or point me to the relevant dox that can tell little ignorant me how to detect a cargo unhook event (and while we are at it, a hook event would also help)? 

Thank you for any pointers,

-ch

 

Posted

At present there are no events associated with hooking or releasing cargo objects. It has been requested. 

 

I think you are just going to have to query cargo objects periodically and check values returned with inAir() or getVelocity() to determine their state. Since they are static objects the only time where inAir would be true or getVelocity wouldn't be 0 is when it is sling loaded. 

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Posted (edited)

This will be a 1 Cargo 1 ZONE setup : 1st Zone size (xxxx large) When the smoke at drop off can be seen by the size of the zone. 

1st zone I will call: Cargo Drop Zone-1  ........  I think the Game wants to see this ZONE NAME "CARGO DROP ZONE" If you had more zones us the -1  -2 -3 like Cargo Drop Zone-3

Zone setup

1 Once Trigger event      CONDITION: UNIT INSIDE ZONE ...... unit: Static UH-1H cargo-1 ..... zone: Cargo Drop Zone-1

                                         ACTION: (Anything you want) LIKE: Message to Group : You Are Clear To Drop Off Cargo at Red Smoke Marker And for fun we will add a                                                                   FLAG ON 30 also.

 

1 Once Trigger event      CONDITION: CARGO UNHOOKED IN ZONE .... unit: Static UH-1H cargo-1 .... zone: Cargo Drop Zone-1 .... FLAG TRUE 30

                                         ACTION: (Anything you want) LIKE Message To Group: Cargo Unhooked You are Clear To Go

                                                         or Flag event or Sound To Group.

 

ALSO My Mission is now Auto hooking the cargo up to my Huey without me pushing any button it will also AUTO unhook the Cargo in the zone when on the ground. This must be new. Or something I have not yet understood. I'm Okay with it. I can still Manually do it too. 

Edited by DishDoggie
Posted

@Grimes Thanks, I was afraid of that. So it's time to write a generic cargo module (seems a bit overkill since I'm sure that the events will be published someday - hopefully - soon, making such a module obsolete. Well, since I like coding I now know what to do over Helloween 🙂 

@DishDoggie thank you for your kind suggestions.

  • Like 1
Posted
3 hours ago, cfrag said:

@Grimes Thanks, I was afraid of that. So it's time to write a generic cargo module (seems a bit overkill since I'm sure that the events will be published someday - hopefully - soon, making such a module obsolete. Well, since I like coding I now know what to do over Helloween 🙂 

@DishDoggie thank you for your kind suggestions.

Yes sorry I wasn't sure I understood your request but other then to say it does detect unhooked cargo in the drop off zone.

You say:  So I wrote a mission where I dynamically spawn nice, juicy and beautiful cargo to transport across DCS world,

That is the part I don't understand. (because I'm Stooped lol) If each cargo has a name Static Cargo-1 Static Cargo-2 Static Cargo-3 and each zone is named Cargo Drop Zone-1 Cargo Drop Zone-2 Cargo Drop Zone-3 

I'm thinking it would work. Thanks and Best of luck to you.

Posted

@DishDoggie you took it upon yourself and invested your own time to respond to my question - I always appreciate that 🙂. That matters more to me than anything else and you have no need to apologize. 

What I'm trying to do is to find out when a helicopter unhooks cargo. That's a problem if that cargo object does not exist in the game at the time I design it in Mission Editor (that's what "dynamically spawned" means: it is created by a script while the game is running, not during mission design). The difficulty here is that for scripts, there currently is no way to detect if a cargo is unhooked, and hence my question. Grime's informed answer is that currently, I'm on my own and that this feature (a cargo unhook event) has been requested for a later release.

  • Like 1
Posted

Some more info for people who are attempting the same to save their time: 

Currently - unless I'm doing something wrong - 

  • cargo:inAir() always returns false for cargo objects, even when hooked and in the air
  • cargo:getVelocity() always returns zero for cargo, even when moving quickly 

This means to determine if the cargo is being lifted, you need to check the object's y position versus the land's y position (a.k.a. AGL calculation). Determine velocity by sampling cargo:getPoint() and compare to last sample. I hope that ED adds correct calculation methods to the cargo object (I assume they are disabled to save processing time, as cargos are part of the static tree, and static objects should not move).

Posted
11 minutes ago, cfrag said:

...This means to determine if the cargo is being lifted, you need to check the object's y position versus the land's y position (a.k.a. AGL calculation)...

Yes, and while a spawned-on-ground cargo has always an AGL altitude of 0, when it is delivered its altitude is never 0, but 0.05 or 0.1 or so, depending on IDK what (but I think you know it if I remember correctly one of your comment in another thread of similar topic). Still doable but not straight forward.

  • Like 1
Posted
On 10/28/2021 at 12:08 PM, cfrag said:
  • cargo:inAir() always returns false for cargo objects, even when hooked and in the air
  • cargo:getVelocity() always returns zero for cargo, even when moving quickly 

 

Reported. 

  • Like 1

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

  • 3 years later...
Posted (edited)

Found this thread and just tested StaticObject:getVelocity() and StaticObject:inAir. Made a simple Trigger outText to dump the boolean from inAir() and the three vector components from getVelocity().

It seems StaticObject:inAir() is still returning false on airborne hooked cargo.

On the bright side, at least I'm getting values for StaticObject:getVelocity(). I used some very basic testing methodology; for the 2nd screenshot I ran the vec3 for each container through Wolfram Alpha, converted the calculated Length to knots true as I'm pretty sure velocity vec3 is in m/s, and compared them to the speeds found in the unit info box. Bear in mind that of course the Observed speeds are being rounded (or truncated - I don't know) to the nearest whole knot, and also this test has shortcomings: since I was lazy and popped the debug using an F10 Radio button I have to execute the function while unpaused and then pause as soon as the info appears on screen.

Cargo 1 vec3: {6.711033821106, 10.801515579224, -49.643314361572} | length 51.246 m/s = 99.614 ktas | observed 95ktas

Cargo 2 vec3: {5.7932195663452, -4.5976705551147, -48.696201324463} | length 49.2546 m/s = 95.743 ktas | observed 96ktas

Cargo 3 vec3: {2.1294958591461, -3.4184143543243, -58.323574066162} | length 58.4624 m/s = 113.642 ktas | observed 114ktas

An edge case and possible explanation for the significant deviation on Cargo 1 would be it had begun decelerating at the edge of a swing when the function dumped the vec3 and had lost 4-5kts velocity when I hit Pause. AI helicopters carrying sling loads are crazy, I've cranked up the mass on these boxes to simulate the weight of an LAV-25 and sometimes they will do a full loop over the helicopter and through the rotor blades.

 

More importantly, this test scenario involved the AI CH-53s dropping off these boxes. Screenshot 3 shows the box on the ground with its velocity values zeroed out! So that would mean now we can at least use the velocity to check when these things are not sling loaded.

Maybe this was noted in a patch? If so I never found/noticed it over the past year or two - but to anyone else who came across this thread and was initially disheartened, fear not, it looks like the velocities do work and can be used to determine when the box comes to rest.

image.png

image.png

image.png

Edited by MechPilot524
apparently "nulls" were added when pasting values from Wolfram Alpha

F-16 | F-15E | AV-8B | A-10C | JF-17 | AH-64D | OH-58D | Ka-50

Comminatus In Via

Posted

Well, it's only been 3 and a half years since the last time this was discussed. ED seemingly is living up to their reputation. Then again, seeing how badly the Hook's cargo systems was fumbled, let's be happy that ED didn't screw this up further. 

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...