Jump to content

Can't detect group in zone after spawning via script


Go to solution Solved by Dirt__,

Recommended Posts

Posted

I have been trying to make a mission where there are randomly spawned ground targets, and when all targets within a zone are destroyed, friendly units capture the zone.
However, I can't seem to detect the groups in the zone, causing me to be unable to know when friendly forces can capture.

I have tried using the "all of coalition out of zone" trigger and the getUnitsInZones MIST function without success, and delay's don't seem to help at all.
When i tried these methods without spawning the groups via code, it all worked fine.

Can someone please take a look at the attached mission and see what i can do to fix this?

ill give a quick rundown of how the mission works:
the tss script has all the functions, the tssZoneController is the script that handeles the moving between zones, and the tssConfig script has the configuration for spawning all the targets and sets up the zone table.
i have commented out some lines that uses the getUnitsInZones function (in the tssZoneController script) to detect empty zones, since it will say every zone is empty. You can test that out if you want.

It would be amazing if someone can find a way to detect an empty zone in any way.

thanks

Dirt-DCS-Campaign-test.zip

Posted

I had a quick look, caveat I don't know the finer details of mist usage/syntax but all looks OK at first glance apart from that the check condition (tssZoneController.lua:92) only ever seems to run on script load and doesnt spin? You might try wrapping in a function and scheduling it to call each second.

Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans.

Discord: PravusJSB#9484   twitch.tv/pravusjsb  https://www.patreon.com/XSAF  https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu

Work with me on Fiverr: https://www.fiverr.com/pravusjsb

Posted
On 5/19/2023 at 4:57 PM, PravusJSB said:

I had a quick look, caveat I don't know the finer details of mist usage/syntax but all looks OK at first glance apart from that the check condition (tssZoneController.lua:92) only ever seems to run on script load and doesnt spin? You might try wrapping in a function and scheduling it to call each second.

@PravusJSB Thank you for your reply.

The tssZoneController script is being run in a repetitive task trigger, so the check should be looped continuously.
But even if it would have one check after the targets have been spawned, it returns with 0 groups, instead of all the groups in the zone.
However, if I set some groups to be in the zone in the mission editor, it returns only with those groups that I spawned in the mission editor.
 

I just build this test mission that doesn't use mist to show you exactly what i mean.
Normally when i use the "out of zone" trigger, it works for both units spawned in the mission editor as well as those spawned via script, as seen in the test mission.
But if i do it in my mission (i did so in the new dirt-dcs-capaign-test file), it will not work for those spawned in the script.
I understand my code is absolute spaghetti, but besides that what could possibly cause this to happen?
The units are right there in the zone but seem to not be detected.

If you or anyone else has any clue how this could happen, or the time to look at my code, that would be amazing.

thanks

test-mission.zip Dirt-DCS-Campaign-test.zip

Posted

I'd have to to check but does mist read the mission file and cache all units for later 'search' use or does it dynamically build a set using world.searchObjects?

Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans.

Discord: PravusJSB#9484   twitch.tv/pravusjsb  https://www.patreon.com/XSAF  https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu

Work with me on Fiverr: https://www.fiverr.com/pravusjsb

  • Solution
Posted
12 hours ago, PravusJSB said:

I'd have to to check but does mist read the mission file and cache all units for later 'search' use or does it dynamically build a set using world.searchObjects?

I am not sure how mist handles that function, but for the example in my last message mist was not used to find the objects. I just used the "all of coalition out of zone" trigger.

However, I sort of managed to fix the problem using this code:

local vehiclesInZone = {}
local sphere = trigger.misc.getZone('zugdidi-5')
local volS = {
    id = world.VolumeType.SPHERE,
    params = {
        point = sphere.point,
        radius = sphere.radius
    }
}
 
local ifFound = function(foundItem, val)
    vehiclesInZone[#vehiclesInZone + 1] = foundItem:getGroup():getName()
    return true
end

world.searchObjects(Object.Category.UNIT, volS, ifFound)

trigger.action.outText(tableToString(vehiclesInZone), 10)

For some reason this works but the "all of coalition out of zone" trigger doesn't.

I'm not going to bother debugging this further and will continue to use this code.
Thanks for your help!

  • Recently Browsing   0 members

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