1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. The poll for our 11th Music Contest is up! Help us choose the most awesome cinematic tracks by casting a vote!
    Dismiss Notice
  3. Melee Mapping contest #3 - Poll is up! Vote for the best 4v4 melee maps!
    Dismiss Notice
  4. The 30th edition of the Modeling Contest is finally up! The Portable Buildings need your attention, so come along and have a blast!
    Dismiss Notice
  5. The Aftermath has been revealed for the 19th Terraining Contest! Be sure to check out the Results and see what came out of it.
    Dismiss Notice

SortGroup [GUI Friendly]

Submitted by Tasyen
This bundle is marked as pending. It has not been reviewed by a staff member yet.
SortGroup automates the access of using Merges Sort by Flux onto an unit group.
This makes it easy to get the members(s) of an group having most/least of an wanted value.
Variable Info


Avaible Sorting modus:

Modus Additional Info
SORTGROUP__MpMax
SORTGROUP__MpLost
SORTGROUP__MpPercent
SORTGROUP__Mp
SORTGROUP__HpMax
SORTGROUP__HpLost
SORTGROUP__HpPercent
SORTGROUP__Hp
SORTGROUP__Level Heroes > non-Heroes
SORTGROUP__Distance needs SortGroupOrigin or X/Y
SORTGROUP__FacingToLoc difference Unit-Facing and Angle to Loc, treating clockwise and anticlockwise the same
needs SortGroupOrigin or X/Y
SORTGROUP__Buffs Any Buff
SORTGROUP__BuffsNeg
SORTGROUP__BuffsPos
SORTGROUP__FlyHeight
SORTGROUP__MoveSpeed
SORTGROUP__CustomData One has to define SortGroupCustomDataTrigger to use it.


Important Variables:

Variable Info
SortGroupGroup the unitgroup you want an sorted unit array from
SortGroupModus the value your sorting is based on
SortGroupAscending true = small to big, false = big to small
SortGroupOrigin needed for FacingToLoc & Distance.
SortGroupAutoDestroy when true will destroy SortGroupGroup and Remove SortGroupOrigin
reset every time to false.
MSort_Indices[index] use this to access the result array in an sorted way.
MSort_EndIndex last index of the result array
SortGroupResult the unitarray, it is not sorted.
SortGroupResultValue the realarray ,it is not sorted.
SortGroupCustomDataTrigger the code which will be executed when choosing customData mod
SortGroupCustomData the value picked unit has, set it inside your SortGroupCustomDataTrigger
SortGroupCustomDataAdjust makes an customdata Value be more heavy/leighter in the sorting


How to use:
This Piece of Code will move all Units from least current Hitpoints to most current Hitpoints to the center of map.
  • HowToUse Wo HP
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set SortGroupGroup = (Units in (Playable map area))
      • Set SortGroupModus = SORTGROUP__Hp
      • Set SortGroupAscending = True
      • Set SortGroupAutoDestroy = True
      • Trigger - Run SortGroup <gen> (ignoring conditions)
      • Set Point[0] = (Center of (Playable map area))
      • For each (Integer A) from 1 to MSort_EndIndex, do (Actions)
        • Loop - Actions
          • Set Point[1] = Point[0] offset by (0.00, (80.00 x (Real((Integer A))))))
          • Unit - Move SortGroupResult[MSort_Indices[(Integer A)]] instantly to Point[1]
          • Custom script: call RemoveLocation(udg_Point[1]
      • Custom script: call RemoveLocation(udg_Point[0])


How to load CustomData:
First you write an small Trigger Loading the data:
  • Load CustomData STR
    • Events
    • Conditions
    • Actions
      • -------- Inside an CustomData Trigger use picked unit to access the unit currently checked. --------
      • Set SortGroupCustomData = (Real((Strength of (Picked unit) (Include bonuses))))
      • -------- Adjust allows to give this unit more/less weight in the sorting. --------
      • Set SortGroupCustomDataAdjust = 0.00

Then Choose Modus = SORTGROUP__CustomData
and set SortGroupCustomDataTrigger = wanted Trigger (Load CustomData STR)
  • CustomData Str
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set SortGroupGroup = (Units in (Playable map area))
      • Set SortGroupModus = SORTGROUP__CustomData
      • Set SortGroupCustomDataTrigger = Load CustomData STR <gen>
      • -------- CustomData needs you to define the trigger used to load the data. --------
      • Set SortGroupAscending = False
      • Set SortGroupAutoDestroy = True
      • Trigger - Run SortGroup <gen> (ignoring conditions)
      • For each (Integer A) from 1 to MSort_EndIndex, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) for 30.00 seconds the text: ((Name of SortGroupResult[MSort_Indices[(Integer A)]]) + ( amount of Str: + (String(SortGroupResultValue[MSort_Indices[(Integer A)]]))))


Credits

Flux
chobibo

Changelog

  • V1.3a HpPercent & MpPercent were incorrect, added into Imports a ini-File useable by GUI-isator.
  • V1.3 Added Sort by HpPercent,MpPercent, added a missing variable for auto generation
  • V1.2 cleans now Index 1, Added adjust
Contents

SortGroup V1.3a (Map)

  1. _Guhun_

    _Guhun_

    Joined:
    Jun 12, 2010
    Messages:
    241
    Resources:
    3
    Spells:
    2
    Tutorials:
    1
    Resources:
    3
    Wow, this looks pretty useful! I like the fact that you also added the possibility of defining your own custom data. I'll test it out when I have the time, so I can give some feedback. But it looking good, and GUI compatibility is always nice xD

    Something like this is great for creating custom abilities, like a triggered AoE heal that prioritizes damaged units. Though there are a lot of other applications one could come up with, too.
     
    Last edited: Jan 16, 2018
  2. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    979
    Resources:
    10
    Tools:
    2
    Maps:
    2
    Spells:
    5
    Tutorials:
    1
    Resources:
    10
    Yeah that's the reason why this was created at the first place, wanted to create an customizeable bouncing spell (supporting both damage and healing as option). After I wrote a version only supporting most/least, I though that could be more useful when allowing to choose more as least/most. Then got the idea that a sorting algo would produce such an behaviour and found some already made on hive. Flux's merge sort seems like a good one, it has a simlear demo, but sortgroup automates the group -> array stuff which most people have to do anyway when using it for groups.

    Think some mod is actually missing but not sure which one it is.
     
  3. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,137
    Resources:
    3
    Models:
    1
    Icons:
    1
    JASS:
    1
    Resources:
    3
    This is what I got from the preview triggers. Please note that this is subject to changes, and may soon be overridden.

    NOTES:


    • Function names are clear, clean and concise.
    • Not really a must-have for most mappers, but can be extremely useful for those with priority schemas.
    • You might want to add a warning to those who would use this to not spam the function calls.
    With that being said, I would say that this is a well-done system, definitely helpful for those who fall under what I have stated above.
     
  4. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,137
    Resources:
    3
    Models:
    1
    Icons:
    1
    JASS:
    1
    Resources:
    3
    Added GUI/Triggers tag as it allows GUIers to utilize the bundle.