Jump to content

Part of Coalition in Zone - (using Script not ME)?


Dangerzone
Go to solution Solved by fargo007,

Recommended Posts

Just wondering if someone can please point me in the right direction. All I'm wanting to do is to detect if part of a coalition is in a zone - but in script, not in the mission editor. Is this possible through script, or do I have to specify units and/or groups instead if I switch from the mission editor to using scripts? 

 

Happy to use MIST/MOOSE/anything that will work. 

 

I've tried placing a triggerzone in the mission editor, and then having units go into this zone and then tried executing the following script just to get started, but I don't get any return. I think I might be way off track and looking in the wrong direction?

 

evhtrig = EVENTHANDLER:New()
evhtrig:HandleEvent(EVENTS.TriggerZone)
function evhtrig:OnEventTriggerZone(EventData)
 local triggerzone = EventData.PlaceName
 BASE:E(" Trigger Zone is  "..triggerzone)

 end

 

Any help turning me around and pointing me in the right direction would be greatly appreciated. 🙂

Link to comment
Share on other sites

A couple ideas.....

 

1 - Use the ME to set flags, then read the value of those flags in a scheduler in your script.

 

2 - In MOOSE entirely, create a SET_GROUP, and filter on coalition.  Create a scheduler that has an appropriate SET iterator method in it that checks for the presence of filtered elements in the zone, e.g. SET_GROUP:ForEachGroupPartyInZone(). 

  • Thanks 1

 

Banner EDForum2020.jpg

Have fun. Don't suck. Kill bad guys. 👍

https://discord.gg/blacksharkden/

Link to comment
Share on other sites

  

16 hours ago, fargo007 said:

A couple ideas.....

 

1 - Use the ME to set flags, then read the value of those flags in a scheduler in your script.

 

2 - In MOOSE entirely, create a SET_GROUP, and filter on coalition.  Create a scheduler that has an appropriate SET iterator method in it that checks for the presence of filtered elements in the zone, e.g. SET_GROUP:ForEachGroupPartyInZone(). 

 

 

Thanks Fargo007...

 

Wow - I was really heading in the wrong direction. Thanks for the tip!

 

I'm very keen in wanting to stay away from the ME and placing triggers in there as much as possible, so I've gone with your other idea. 

 

I'll create the following for each of my zones that I want a trigger for. Might be more lines than using the ME but at least I can do copy/paste much easier when it comes to monitoring lots of zones and having custom actions for each. 🙂

 

 zonetrigger = SCHEDULER:New(nil, 
    function()
       local blufor = SET_GROUP:New():FilterCoalitions('blue'):FilterCategoryGround():FilterStart()

       if zone1triggered ~= true then 
         local myzone = ZONE:FindByName("zone1")
         if blufor:AnyInZone(myzone) then
           BASE:E(myzone.ZoneName.. "  Infiltrated ")
           MESSAGE:New(myzone.ZoneName.." under attack" ,5):ToAll()
           MESSAGE:New("zone under attack" ,5):ToAll()
           zone1triggered = true
         end  
       end
       
       if zone2triggered ~= true then 
         local myzone = ZONE:FindByName("zone2")
         if blufor:AnyInZone(myzone) then
           BASE:E(myzone.ZoneName.. "  Infiltrated ")
           MESSAGE:New(myzone.ZoneName.." under attack" ,5):ToAll()
           MESSAGE:New("zone under attack" ,5):ToAll()
           zone2triggered = true
         end  
       end
       
   end, {}, 1, 5) --zonetrigger Scheduler

 

 

Thanks very much for your help!


Edited by Dangerzone
Link to comment
Share on other sites

NP, I'll add that the declaration of the SET_GROUP doesn't need to live in the scheduler, as you're declaring it newly every single time.

 

More efficient to have it not be local, and be declared outside the scheduler, only once.  🙂

 

Now that I've seen what you're after, you can also have a look at zone_capture_coalition, which sort of does what you are doing, right out of the box. 

 

e.g.

 

 

I got lots of help when I started with all this, so I'm very happy to pass it forward.

 

 

Banner EDForum2020.jpg

Have fun. Don't suck. Kill bad guys. 👍

https://discord.gg/blacksharkden/

Link to comment
Share on other sites

  

On 5/15/2021 at 1:42 AM, fargo007 said:

Now that I've seen what you're after, you can also have a look at zone_capture_coalition, which sort of does what you are doing, right out of the box. 

 

I got lots of help when I started with all this, so I'm very happy to pass it forward.

 

 

 

Thanks so much fargo007 for your help with this and your offer to pay it forward! It's very generous of you!


Firstly - sorry for misleading you with the above script - I should have explained in more detail what I'm trying to do - the message is misleading. At this stage I just want to detect when a unit is in that zone. The zone won't actually be fought over or capturable in my instance - but I have enough information to get me going. Thank you!

 

And thanks for the great point regarding SET_GROUP in the scheduler. However I have a problem at the moment with SET_GROUP in that it does not include non-active CLIENT players within the list when it's executed. So if I do this as a non-local variable at the start of the mission, and then later a new player joins in - they will be ignored. (At least that's what I think will happen from my experimentation).  So I don't see any other workaround at the moment but to repeat the call to SET_GROUP?


Edited by Dangerzone
Link to comment
Share on other sites

On 5/17/2021 at 11:21 PM, fargo007 said:

Clients are different objects, so to manage those best you'd want a different set (SET_CLIENT).

 

And no, the sets do update dynamically (if configured to do so, e.g. :FilterStart()

 

 

 

 

Bingo! Exactly what I needed. I was missing the FilterStart() at the end which only executed it the once!  Sorry for the noob questions - but I really appreciate the help! I feel like I'm well on my way now!

Link to comment
Share on other sites

  • 2 years later...
  • Recently Browsing   0 members

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