• 🏆 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!

[Trigger] How would I get this to work

Status
Not open for further replies.
Level 6
Joined
Feb 10, 2011
Messages
188
I am trying to check if a player owns all units in unit group, but first. here is my trigger that sets country regions and adds the bases in a country region to a unit group (lets call the unit group country group)

  • Set Countries
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set countryArea1[1] = Region 000 <gen>
      • Set countryArea1[2] = Region 001 <gen>
      • Set countryArea1[3] = Region 002 <gen>
      • Set countryArea1[4] = Region 003 <gen>
      • Set countryArea1[5] = Region 004 <gen>
      • Set countryArea2[5] = Region 005 <gen>
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Unit Group - Add all units of (Units in countryArea1[(Integer A)] matching (((Unit-type of (Matching unit)) Equal to City) or ((Unit-type of (Matching unit)) Equal to Port))) to countryRegions[(Integer A)]
          • Unit Group - Add all units of (Units in countryArea2[(Integer A)] matching (((Unit-type of (Matching unit)) Equal to City) or ((Unit-type of (Matching unit)) Equal to Port))) to countryRegions[(Integer A)]
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Set countryCityCount[(Integer A)] = (Number of units in countryRegions[(Integer A)])
now i need a trigger that would run every 60 seconds and it will check if a player owns all bases in a country group

but i cant figure out how to check it via conditions

any ideas?
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • 'IF'-Conditions
      • (g is empty) Equal To True
    • 'THEN'-Actions
      • Set p = Neutral passive
    • 'ELSE'-Actions
      • Set p = (Owner of (Random unit from g))
      • Unit Group - Pick every unit in g and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • 'IF'-Conditions
              • (Owner of (Picked unit)) Not Equal To p
            • 'THEN'-Actions
              • Set p = Neutral passive
            • 'ELSE'-Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • 'IF'-Conditions
      • p Not Equal To Neutral passive
    • 'THEN'-Actions
      • //praise the king
    • 'ELSE'-Actions
Marking Neutral Passive as invalid player.
 
Level 6
Joined
Feb 10, 2011
Messages
188
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • 'IF'-Conditions
      • (g is empty) Equal To True
    • 'THEN'-Actions
      • Set p = Neutral passive
    • 'ELSE'-Actions
      • Set p = (Owner of (Random unit from g))
      • Unit Group - Pick every unit in g and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • 'IF'-Conditions
              • (Owner of (Picked unit)) Not Equal To p
            • 'THEN'-Actions
              • Set p = Neutral passive
            • 'ELSE'-Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • 'IF'-Conditions
      • p Not Equal To Neutral passive
    • 'THEN'-Actions
      • //praise the king
    • 'ELSE'-Actions
Marking Neutral Passive as invalid player.

ah thanks nice simple and straight to the point, this works perfect.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Would not say it's efficient. The Is Unit Group Empty function for example iterates over the whole group internally and so do I in this snippet. Was just more convenient to do it this way in GUI. Better would it be to write a function and return on the first sight of another owner.
 
Level 6
Joined
Feb 10, 2011
Messages
188
Would not say it's efficient. The Is Unit Group Empty function for example iterates over the whole group internally and so do I in this snippet. Was just more convenient to do it this way in GUI. Better would it be to write a function and return on the first sight of another owner.

well to be honest i know nothing about jass, so i dont thinking writing a function and being able to use it would really be a option for me haha, well is there a way to make this efficient via GUI? and also it would have to be used for multiple unit groups (up to around 60 i believe) i was just going to loop it for each group
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
It's still efficient enough for a GUI user. Besides you won't have thousands of occupyable structures. And if it was really about that, one would pick another approach in the first place like setting up data structures beforehand, reacting on the take-over and probably not checking periodically.
 
Level 6
Joined
Feb 10, 2011
Messages
188
@rollindoubles
u should stop using integer A/B
they are slower and less efficient than using ur own integer.

i usually use use A/B when i am testing triggers. Once i figure them out i changed that and clean leaks usually. but ty. while we are on the subject though if i made a custom integer A/B would it still be slow?
 
Status
Not open for further replies.
Top