• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[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>)
 
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>)
 
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.
 
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?
 
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.
 
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.
Back
Top