[Unsolved] Question Regarding Loop Actions

Chaltier

Cool Member
Reaction score
0
[Solved] Question Regarding Loop Actions

I'm making an AoS map and have a question regarding loop action triggers.

Basically, what I want to do is this:

PHP:
Players A, B, C & D spawn units at a given rate normally.
If Players A, C or D have units near Player B's base, Player B gets a few more units
   per spawn.
If Players A, C, or D have units [I]in[/I] Player B's base, Player B gets several more
   units per spawn.

The thing is that using non-loop triggers I can only do "If [region] contains [random unit owned by [player]], do [actions]," whereas what I want is "If [region] contains [any unit] owned by [enemy of [player]], do [actions]," so I'm forced to use a double loop, but it clearly isn't working as I intend as one player gets massive spawns every time that condition is met.

I honestly don't know what a loop means in JASS or how to close one so it only does things once. I've tried [Skip Remaining Actions] but haven't tried defining variables, which was my next thought - that's a lot of work if I'm not sure it's the solution. At any rate, if anyone knows how to achieve the desired result thanks in advance for letting me know.

Here's what I've got right now for Player A (mirrored for the rest):

PHP:
Player Group - Pick every player in (All enemies of Player 1 (Red)) and do (Actions)
    Loop - Actions
        Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (RedBase <gen> contains (Picked unit)) Equal to True
                    Then - Actions
                         Set LeakSpawnPoint1 = (Random point in [region] <gen>)
                         Unit - Create 1 [unit] for Player 1 (Red) at LeakSpawnPoint1 facing
                           Default building facing degrees
                         Custom script:   call RemoveLocation(udg_LeakSpawnPoint1)
                         [et c. for more units]
                     Else - Actions
 

akuzaid93

New Member
Reaction score
3
Trigger:
  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Picked unit) belongs to an enemy of Player 1 (Red)) Equal to True
        • Then - Actions
        • Else - Actions


wouldn't this work?
 

Chaltier

Cool Member
Reaction score
0
It definitely makes the trigger look prettier and avoids two loops, so thanks for that tip! Still, it seems I run into the same problem with just one: the spawn cycle is endless when the conditions are met.

Is there some way to make a loop... well, not loop? I only want its 'Pick every unit...' function and for it to run once. :(
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
Trigger:
  • (Number of units in (Units owned by Player 1 (Red) matching ((YourRegion contains (Matching unit)) Equal to True))) Greater than or equal to 1

Wouldn't this be enough?
 

CAPSLOCKFTW

Member
Reaction score
5
havent got editor right now so ill just clarify in english

"player1base" is region
"str" is boolean

Spawning trigger
event - every 30 seconds
conditions -
actions -
pick all units that are enemies of "player1"
if "player1base" contains picked unit's Then
str = true
else
str = false
end if
end

if "str" equals true then
"SPAWN STRONGER UNITS"
end if

if str equals false then
"SPAWN WEEK UNITS"
end if

This should work... only that picked units should be stored in a variable so that u can clean leak later :D
 

Chaltier

Cool Member
Reaction score
0
Hm, leaky solutions aren't my favourites but that seems to work. Thanks!

Still, if anyone could enlighten me nonetheless as to the difference between a 'Loop' and a normal set of 'Actions', I'd be grateful.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top