Snippet Emulating Pick Every X Functions

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
Emulating Pick Every Functions

This is a brief introduction on picking every player/unit/w.e u want to pick without using the actual functions
Essentially what the pick every unit function does, is it goes down a list of the units in a group doing a set of actions for each one. What we will do here is emulate this effect through the use of integer loops and variables, here is an example of a very basic one:
Trigger:
  • Emulated Pick Every unit
    • Events
      • A Unit casts an ability
    • Conditions
      • Ability being cast is equal to Stomp (a triggered spell that deals damage in an aoe)
    • Actions
      • Set Damaged_Units (our unit group) = Units within 300 range of casting unit matching conditions (Owner of matching unit is an enemy of Owner of casting unit)
      • For each Integer A from 1 to (number of units in Damaged_Units) do actions.
        • Loop Actions
          • Set Picked_Unit = Random Unit from Damaged_Units
          • Unit Group - Remove Picked_Unit from Damaged_Units
          • Unit - Cause Casting Unit to damage Picked_Unit for X damage
      • Custom Script: Calldestroygroup(UDG_Damaged_Units)
As you can see there, what I did was set the group that i would have used in the Pick every unit function and instead used an Integer Loop, setting the "Picked unit" to a random unit in that group and then removing it until all units have been removed

This is best for use with picking every unit inside a picked unit function IE: a spell that deals damage to the enemies around your nearby allies, a spell like earthshaker's ult (a seismic wave that hits enemies in an aoe hit then hits nearby enemies for a lesser ammount)

Here is an example of this:
Trigger:
  • Echo-Slam
    • Events
      • A unit finishes casting an ability
    • Conditions
      • Ability being cast is equal to Echo-Slam
    • Actions
      • Set Temp_GRP[1] = Units within 300 range of casting unit matching conditions (owner of matching unit is an enemy of owner of casting unit)
      • Unit Group - Pick every unit in Temp_GRP[1] and do actions
        • Loop Actions
          • Unit - Cause Casting unit to damage Picked unit for 150 damage
          • Set Temp_GRP[2] = Units within 300 range of picked unit matching conditions (Owner of matching unit is an enemy of owner of casting unit)
          • For Each Integer A from 1 to (Number of units in Temp_GRP[2]) do actions
            • Loop Actions
              • Set Picked_Unit = Random unit in Temp_GRP[2]
              • Unit Group - Remove Picked_Unit from temp_GRP[2]
              • Unit - Cause Casting Unit to damage Picked_Unit for 75 Damage
          • Custom Script: Calldestroygroup(UDG_Temp_GRP[2])
      • Custom Script: Calldestroygroup(UDG_Temp_GRP[1]
In this example the caster deals damage to enemies in 300 range for 150 damage, then deals damage to enemies within 300 range of them for 75 damage, creating a sort of chain aoe effect. The nice thing about using an effect like this with an Integer A loop is that you if you want to have a picked unit in a picked unit in a picked unit, you can do it as many times as you want with just the A loop, changing indexes for the stored units every level or dimension, this is because you dont actually use Integer A in your actions.

Any questions/comments you can pm or post here :)
 

Dirac

22710180
Reaction score
147
Well i have one question:
Speaking in GUI terms how is this useful? you can always pick groups inside group picking, i've done it several times before back when i did GUI coding.
Looks like much more overhead for GUI users to go this way, however in JASS it's the easiest way to do it
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
i did some reasearch and it appeared that using that method causes glitches with what unit is the picked unit, is that incorrect?
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
Hm looks like the gui version of first of group iteration except both number of units and random unit call ForGroup/Pick unit =).

It's kinda strange that unit groups don't know their size...
 

tooltiperror

Super Moderator
Reaction score
231
This isn't really a tutorial on its own.

You could submit a tutorial on all kinds of group management, or make a demo map showing a bunch of stuff about using groups well or whatever. This itself does not merit a tutorial.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    Happy Sunday!
    +1
  • The Helper The Helper:
    I will be out of town until Sunday evening
    +1
  • The Helper The Helper:
    I am back! Did you miss me LOL
    +1
  • jonas jonas:
    where did you go?
  • The Helper The Helper:
    Jefferson TX on a Paranormal Investigation of a haunted bed and breakfast - I got some friends that are paranormal investigators and they have an RV and do YouTubes
    +1
  • The Helper The Helper:
    It was a lot of fun. The RV was bad ass
  • jonas jonas:
    That sounds like fun!
    +1
  • The Helper The Helper:
    it was a blast!
  • The Helper The Helper:
    I am going to post the Youtube of the investigation in the forums when it is ready
    +1
  • jonas jonas:
    cool!
  • vypur85 vypur85:
    Sounds cool TH.
  • tom_mai78101 tom_mai78101:
    I was on a Legend of Zelda marathon...
  • tom_mai78101 tom_mai78101:
    Am still doing it now
    +1
  • jonas jonas:
    which one(s) are you playing?
  • jonas jonas:
    I played a little bit of the switch title two weeks ago and found it quite boring
  • The Helper The Helper:
    just got back from San Antonio this weekend had the best Buffalo Chicken Cheesesteak sandwhich in Universal City, TX - place was called Yous Guys freaking awesome! Hope everyone had a fantastic weekend!
    +1
  • The Helper The Helper:
    Happy Tuesday!
  • The Helper The Helper:
    We have been getting crazy numbers reported by the forum of people online the bots are going crazy on us I think it is AI training bots going at it at least that is what it looks like to me.
  • The Helper The Helper:
    Most legit traffic is tracked on multiple Analytics and we have Cloud Flare setup to block a ton of stuff but still there is large amount of bots that seem to escape detection and show up in the user list of the forum. I have been watching this bullshit for a year and still cannot figure it out it is drving me crazy lol.
    +1
  • Ghan Ghan:
    Beep boop
    +1
  • The Helper The Helper:
    hears robot sounds while 250 bots are on the forum lol
  • The Helper The Helper:
    Happy Saturday!
    +1

    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