Jump to content

Checking sling load for damage


Yurgon

Recommended Posts

I'm experimenting with Sling Loads for the 1.2.8 Open Beta Huey, and I can't figure out how to detect if the player has damaged or destroyed the external cargo.

 

I've tried the conditions "Unit Dead" and "Unit Damaged" on static cargo objects (Static Object, Category Cargo, Type "Cargo1").

 

What happens then is that as soon as I hook such a cargo up, the trigger fires, even though the cargo looks alright, and if I gently put the cargo on the ground and release it, it's once again available in the F6 "All Cargos" menu, so it doesn't seem to be damaged, and it's definitely not destroyed.

 

I also tried the condition "Group Alive Less Than" with values going as high as 90%, but then the trigger never fires even if I drop the cargo in a way that it is no longer available.

 

So, are there any other ways to detect the status of cargo and check if the player damaged it?

Link to comment
Share on other sites

Cargo Destroyed Triggers

 

The problem is when cargo is hooked to the sling it is no longer alive, yet not technically dead. It seems to go into 'DCS purgatory'. However, it still activates the 'unit dead' trigger.

 

A way around this is to create a Switched Condition trigger that turns on a flag when the cargo goes 'purgatory dead' and switches the flag off when it becomes 'alive' again.

 

For the 'Cargo Loaded' trigger use:

Switched Condition -> Flag is False(10) AND Unit Dead(cargo1) -> Flag On (10)

 

For the 'Cargo Unloaded' trigger use:

Switched Condition -> Flag is True(10) AND Unit Alive(cargo1) -> Flag Off(10)

 

Then to check if the cargo is destroyed use the 'ON DESTROY' event.

ONCE - ON DESTROY -> Flag is True(10) -> Message to All ("Cargo 1 has been destroyed")

 

Unfortunately, the cargo can only be checked if damaged or dead when it is no longer connected to the sling and 'out of purgatory'. So if someone damages their cargo mid-flight, they cannot know whether it is damaged until they release it from the sling.

 

Attached is an example mission using the method I have described.

Damaged Cargo Example.miz

  • Like 1
Link to comment
Share on other sites

The problem is when cargo is hooked to the sling it is no longer alive, yet not technically dead. It seems to go into 'DCS purgatory'. However, it still activates the 'unit dead' trigger. [...]

 

Wow, that's a great explanation, thanks a lot! :thumbup:

 

Your example was also very helpful. I'm not quite done yet integrating this into a mission I've been building for the past couple of days, but I think I'm 95% there (well, I always think that anywhere beyond 25%, but that's another matter :D).

 

That also forced me to finally figure out what a SWITCHED CONDITION is and how it works. Turns out, besides the confusing name (IMO), it's not that difficult after all. :)

Link to comment
Share on other sites

Update: I've finished the mission for which I needed this info: SP Mission: Parcel Carrier.

 

I did run into a few problems with triggers firing simultaneously. For instance if I unhooked cargo so that it would get destroyed on touchdown, the events "Cargo unloaded" and "Cargo destroyed" overlapped.

 

I chose to check the destruction event in Lua instead. This seemed more solid, and also much more flexible when more cargo units are added to the mission (for this mission I always had three cargoes in mind and the triggers already became a bit confusing, but the way I'd implemented them they would be almost impossible to handle with, say, 15 cargoes).

 

In case it's of interest to anyone, this is my cargo-destruction detection script, taken right out of the mission.

 

Mission Start -> No condition -> DO SCRIPT

 

cargoDead = {}

cargos = {
 ["Cargo Construction"] = { ["flag"] = 30, ["desc"] = "The cargo for the construction site" },
 ["Cargo Denton"] = { ["flag"] = 31, ["desc"] = "The package of goods for FOB Denton" },
 ["Cargo Jensen"] = { ["flag"] = 32, ["desc"] = "The parcel for FOB Jensen" },
}

function cargoDead:onEvent(e)
 if e.id == world.event.S_EVENT_DEAD and
    e.initiator and
    e.initiator:getCategory() == Object.Category.STATIC then
   for name, data in pairs(cargos) do
     if string.lower(name) == string.lower(e.initiator:getName()) then
       trigger.action.outSound("RadioClickAfter.wav")
       trigger.action.outText(data.desc .. " has been destroyed.", 15)
       trigger.action.setUserFlag(data.flag, 1);
     end
   end
 end
end

world.addEventHandler(cargoDead)

 

Besides the obvious sound and the text message, the really important bit here is that the flags 30, 31 or 32 respectively will be set to 1 when the cargo object is destroyed.

 

Then using standard triggers without any more Lua, I can check these flags. For the first cargo object, the triggers look like this:

 

Cargo #1 picked up

Switched Condition -> Flag is False(5) AND Flag is False(30) AND Unit Dead(Cargo construction) -> Flag On(5) AND Message to All("Cargo 1 picked up")

 

Cargo #1 delivered outside intended zone

Switched Condition -> Flag is True(5) AND Flag is False(30) AND Unit Alive(Cargo construction) AND Unit Outside Zone(Cargo construction, Drop Zone 1) -> Flag Off(5) AND Message to All("Cargo 1 bad delivery")

 

Cargo #1 good delivery

ONCE (NO EVENT) -> Flag is False(30) AND Unit Inside Zone(Cargo construction, Drop Zone 1) -> Flag Off(5) AND Message to All("Cargo 1 good delivery")

Link to comment
Share on other sites

  • 1 year later...

I'm trying the sling load hooked/unhokked detection proposed by AlaskanGrizzly on the current build of 1.5 beta, but something is not working. Can anybody tell me if the feature is broken? (otherwise I'm doing something wrong, I guess...)

Link to comment
Share on other sites

AFAICT it's currently broken. My old mission "Parcel Carrier" doesn't detect cargo pickups in 1.5 and unless I've misread a bunch of posts, proper cargo detection hasn't worked for a long time (well before 1.5).

 

I'll try and keep an eye out for a solution to this.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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