[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.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top