• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] 3 units in 3 regions condition

Status
Not open for further replies.
Level 6
Joined
Sep 24, 2015
Messages
174
How can I manage to activate a waygate only if there are 3 units of the same type in 3 different regions?

Tried this but i guess the event is not correct or conditions...

  • Gold supply opening
    • Events
      • Unit - A unit enters Slayer open 1 <gen>
      • Unit - A unit enters slayer open 2 <gen>
      • Unit - A unit enters slayer open 3 <gen>
    • Conditions
      • (Number of units in (Units in Slayer open 1 <gen>)) Equal to 1
      • (Number of units in (Units in slayer open 2 <gen>)) Equal to 1
      • (Number of units in (Units in slayer open 3 <gen>)) Equal to 1
    • Actions
      • Neutral structure - Activate Slayer portal 0022 <gen>
      • Neutral structure - Set Slayer portal 0022 <gen> destination to (Center of gold supplier in <gen>)
 
Level 28
Joined
Feb 18, 2014
Messages
3,579
You can try this :
  • Trigger
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • (Number of units in (Units in Region 001 <gen> matching ((Unit-type of (Matching unit)) Equal to Footman))) Greater than 0
      • (Number of units in (Units in Region 002 <gen> matching ((Unit-type of (Matching unit)) Equal to Footman))) Greater than 0
      • (Number of units in (Units in Region 003 <gen> matching ((Unit-type of (Matching unit)) Equal to Footman))) Greater than 0
    • Actions
      • Trigger - Turn off (This trigger)
      • Neutral Structure - Activate Waygate 0000 <gen>
      • Neutral Structure - Set Waygate 0000 <gen> destination to (Center of Waygate Destination <gen>)
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,195
You can try this :
That trigger leaks badly, and is inefficient.

Simplest would be to set boolean variables every time an appropriate unit enters/leaves a region. If appropriate unit enters region, set region's variable true. If appropriate unit leaves region, then test if region contains any appropriate units and if not then set region's variable to false. When any of the regions are entered and the above logic has run then test the region variables if they are all true, and if so then run your actions.
 
Level 28
Joined
Feb 18, 2014
Messages
3,579
That trigger leaks badly, and is inefficient.

Simplest would be to set boolean variables every time an appropriate unit enters/leaves a region. If appropriate unit enters region, set region's variable true. If appropriate unit leaves region, then test if region contains any appropriate units and if not then set region's variable to false. When any of the regions are entered and the above logic has run then test the region variables if they are all true, and if so then run your actions.
He can also use an Integer, will it leak?
 
Level 6
Joined
Sep 24, 2015
Messages
174
so it would be like: variable set>slayer=unit entering region=true as a boolean variable? I don't know how to do this trigger it's kinda of hard for me :/
 
For GUI, I would use 3x PickAllUnitsInRegion, and then check if there are enough wanted units inside, similar like Warseeker suggested.
Though the trigger needs to destroy the 3 unit groups again, using a tiny custom script: Things That Leak
Do the work inside Actions, not in Conditions, and use "Enter/Leave" event, instead of periodic event.
For Dr Super Good's way you would need some more knowledge how regions and rects work in GUI, so it's I think a prefered way for JASS.
 
Level 6
Joined
Sep 24, 2015
Messages
174
hmm, but for the unit enters a region i have to do 3 triggers? cause it's 3 different regions or can i put 3 event like :

events:
a unit enters region x
a unit enters region y
a unit enters region z

condition :
(Number of units in (Units in region x <gen> matching ((Unit-type of (Matching unit)) Equal to Slayer))) greater than 0
(Number of units in (Units in region y <gen> matching ((Unit-type of (Matching unit)) Equal to Slayer))) greater than 0
(Number of units in (Units in region z <gen> matching ((Unit-type of (Matching unit)) Equal to Slayer))) greater than 0

actions:
custom script: set bj_wantDestroyGroup = true
turn off this trigger
activate gate way

or is that not correct?
 
Status
Not open for further replies.
Top