Snippet Emulating Pick Every X Functions

GFreak45

I didnt slap you, i high 5'd your face.
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
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.
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
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
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.
  • jonas jonas:
    cool! do you have a video?
  • tom_mai78101 tom_mai78101:
    I have a GIF though
  • tom_mai78101 tom_mai78101:
    In the GIF, I've configured it so the lower the "Main Value" is, the better. I had to compress it pretty far down though.
  • tom_mai78101 tom_mai78101:
    And this is the thread with the video that shows the wall clip. https://tasvideos.org/Forum/Topics/23453
    +2
  • tom_mai78101 tom_mai78101:
    Hmm, about the Headline News, I noticed threads are being moved into the subforum (Health News, Environmental News, etc.). When that happens, the TH Forum Home page loses the articles, and instead would show old articles posted 1 or 2 weeks ago.
  • tom_mai78101 tom_mai78101:
    What do we do with the Home page?
  • Ghan Ghan:
    I added those forums to the filter for that widget.
  • tom_mai78101 tom_mai78101:
    Oh nice. They're back. Thanks.
  • tom_mai78101 tom_mai78101:
    Now I think it makes more sense for me to put news in their own subforums, without worry.
  • The Helper The Helper:
    Awesome Ghan thanks! I was purposely not moving the first 15 news articles in Headline news to the different subforums but I guess I don't have to do that now?
  • tom_mai78101 tom_mai78101:
    Question: Is there a way to remove thread redirects? It creates a copy of the moved thread and takes up space, and I am leaning towards wanting to remove them in the Headline News. But if they have an expiration date, I guess I'm fine with it.
  • The Helper The Helper:
    If you move a thread please leave a permanent redirect. You can delete any redirects after 6 months. The redirects are left to help Search Engines find the moved content.
  • tom_mai78101 tom_mai78101:
    What if you move the permanent redirect, not the thread?
  • The Helper The Helper:
    I think that works but I have not messed with it. You can delete redirects though if you have to that will not delete the original thread
  • The Helper The Helper:
    if a redirect ends up in the same forum as the post it goes to though I think the redirect drops or fails or something but they are not bugged out and when you are working on an indirect the original post is safe.
  • The Helper The Helper:
    Happy Early Friday :)
    +1
  • V-SNES V-SNES:
    Happy Friday :)
  • tom_mai78101 tom_mai78101:
    Fun Friday for me
  • tom_mai78101 tom_mai78101:
    Happy Fun Friday to all.
    +2
  • The Helper The Helper:
    Happy Sunday everyone!!!
  • V-SNES V-SNES:
    Happy Sunday!!!
    +1
  • jonas jonas:
    Happy monday :p
  • jonas jonas:
    Everyone hates mondays?
    +1
  • The Helper The Helper:
    Happy Tuesday!

    Staff online

    Members online

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top