System Mass Unit Ordering

Tru_Power22

You can change this now in User CP.
Reaction score
144
Mass Unit Ordering​

Newest Version: 1.2​

General Information:

This is just a simple system for ordering more than 12 units at one time. Easy to implement and easy to use. Why should you use this? It's lagless, and GUI (FTW).

Requires Jassnewgen pack with UMSWE enabled.

How to implement:

Copy over all the triggers used in the system. Make sure you have "Automatically create unknown variables while pasting trigger data" is enabled in the World Editor general preferences.

How to enable:

Press escape in game to turn it on. If you want it enabled by default change the variable MUO_Enabled to "true".

Configureation:

You can change the number of units that need to be selected in order to get this to run. Simply change MUO_Units_Needed to whatever number you want.

Known Issues:
If you select enough unit to trigger the mass ordering and the randomly picked unit is not the one you intended it may move every unit of the wrong type.

Leaks a group.

Code:

Initialization Trigger:
Trigger:
  • MUO Init Player Selection Events Iniltalization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Do Multiple ActionsFor each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Trigger - Add to MUO Unit selection <gen> the event (Player - (Player((Integer A))) Selects a unit)
          • Trigger - Add to MUO Mass Unit Ordering Toggle <gen> the event (Player - (Player((Integer A))) skips a cinematic sequence)


Storing the unit type of the units selected
Trigger:
  • MUO Unit selection
    • Events
    • Conditions
    • Actions
      • -------- Sets the temp group units currently selected by triggering player. This is to prevent leaks. --------
      • Set MUO_Temp_Group = (Units currently selected by (Triggering player))
      • Set MUO_Temp_Unit = (Random unit from MUO_Temp_Group)
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Number of units in MUO_Temp_Group) Greater than or equal to (>=) MUO_Units_Needed
          • Then - Actions
            • -------- Sets the selected unit type to the first unit in the group (units currently selected by triggering player). --------
            • Custom script: set udg_MUO_SelecteUnitType[GetConvertedPlayerId(GetTriggerPlayer())] = GetUnitTypeId(udg_MUO_Temp_Unit)
          • Else - Actions
      • -------- Destoyes the unit group --------
      • Custom script: call DestroyGroup (udg_MUO_Temp_Group)


The toggling trigger to turn the system on and off.

Trigger:
  • MUO Mass Unit Ordering Toggle
    • Events
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MUO_Enabled[(Player number of (Triggering player))] Equal to (==) True
        • Then - Actions
          • -------- Enables the massive movemnet --------
          • Set MUO_Enabled[(Player number of (Triggering player))] = False
          • Set MUO_Temp_Force = (Player group((Triggering player)))
          • Game - Display to MUO_Temp_Force the text: Massive Unit Select...
          • Custom script: call DestroyForce( udg_MUO_Temp_Force )
        • Else - Actions
          • -------- Disables the massive movemnet --------
          • Set MUO_Enabled[(Player number of (Triggering player))] = True
          • Set MUO_Temp_Force = (Player group((Triggering player)))
          • Game - Display to MUO_Temp_Force the text: Massive Unit Select...
          • Custom script: call DestroyForce( udg_MUO_Temp_Force )


Mass ordering point targeted:

Trigger:
  • MUO Unit Actions Point Targeted
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • MUO_Enabled[(Player number of (Triggering player))] Equal to (==) True
    • Actions
      • -------- Turns off the trigger so it doesn't run in in infinite loop. --------
      • Trigger - Turn off (This trigger)
      • Set MUO_Order_Issued = (Issued order)
      • Set MUO_Temp_Point = (Target point of issued order)
      • Set MUO_Temp_Group = (Units of type MUO_SelecteUnitType[(Player number of (Triggering player))])
      • Unit Group - Pick every unit in MUO_Temp_Group and do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to (==) (Triggering player)
            • Then - Actions
              • Unit - Order (Picked unit) to MUO_Order_Issued MUO_Temp_Point
            • Else - Actions
      • -------- Null unit type to prevent leaks --------
      • Custom script: call DestroyGroup (udg_MUO_Temp_Group)
      • Custom script: call RemoveLocation (udg_MUO_Temp_Point)
      • Custom script: set udg_MUO_Order_Issued = 0
      • -------- Turns on the trigger so it will run again. --------
      • Trigger - Turn on (This trigger)


Mass ordering unit targeted:

Trigger:
  • MUO Unit Actions Unit Targeted
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • MUO_Enabled[(Player number of (Triggering player))] Equal to (==) True
    • Actions
      • -------- Turns off the trigger so it doesn't run in in infinite loop. --------
      • Trigger - Turn off (This trigger)
      • Set MUO_Order_Issued = (Issued order)
      • Set MUO_Temp_Unit = (Target unit of issued order)
      • Set MUO_Temp_Group = (Units of type MUO_SelecteUnitType[(Player number of (Triggering player))])
      • Unit Group - Pick every unit in MUO_Temp_Group and do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to (==) (Triggering player)
            • Then - Actions
              • Unit - Order (Picked unit) to MUO_Order_Issued MUO_Temp_Unit
            • Else - Actions
      • -------- Null unit type to prevent leaks --------
      • Custom script: call DestroyGroup (udg_MUO_Temp_Group)
      • Custom script: set udg_MUO_Order_Issued = 0
      • -------- Turns on the trigger so it will run again. --------
      • Trigger - Turn on (This trigger)


-------------
Screenshot:
WC3ScrnShot_121209_161218_06.png


Changelog:
1.1: Fixes an enum units leak. Thanks Sickle! - Nevermind I fixed it in the next version.
1.2: Instead of getting the first unit from the group. I pick a random unit to avoid the enum leak. I also removed a few redundant lines of code.

That's everything. Not a super complicated system, but hopefully any maps dealing with a lot of units may find this handy.
 

Attachments

  • Mass Unit Ordering 1.0.w3x
    26.2 KB · Views: 225
  • Mass Unit Ordering 1.1.w3x
    26.3 KB · Views: 253
  • Mass Unit Ordering 1.2.w3x
    26.3 KB · Views: 219

Sickle

New Member
Reaction score
13
The party pooper is here to tell you that your system is not leakless. Every time you enumerate the units selected by a player in GUI, it leaks.
 

Tru_Power22

You can change this now in User CP.
Reaction score
144
The party pooper is here to tell you that your system is not leakless. Every time you enumerate the units selected by a player in GUI, it leaks.

So when I get the first unit for the unit group? I can fix that by just setting it to a temp unit then nulling it. Give me a sec.
 

Sickle

New Member
Reaction score
13
No. And, by the way, nulling integers and reals does nothing. Unit types are integers.

The GUI action leaks internally and cannot be fixed without replacing it totally.
 

Sickle

New Member
Reaction score
13
[lJASS]call GroupEnumUnitsSelected(udg_GroupVariable, udg_PlayerVariable, null)[/lJASS]

And the group must be created first on map initialization.

[lJASS]set udg_GroupVariable = CreateGroup()[/ljASS]
 

Tru_Power22

You can change this now in User CP.
Reaction score
144
I'm just going to get a random unit from the group instead. That way I don't need to change much, and it was kind of pointless for me to get an enumerated unit seeing as when they are added to group by selection it's fairly random anyway.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Interesting idea, I think it would be a lot easier to simply create it in (v)Jass, as it would allow many more features (such as ordering all selected unit-types within range).

I thought getting a random unit didn't enumerate them.

It does:

JASS:
function GroupPickRandomUnit takes group whichGroup returns unit
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    set bj_groupRandomConsidered = 0
    set bj_groupRandomCurrentPick = null
    call ForGroup(whichGroup, function GroupPickRandomUnitEnum)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(whichGroup)
    endif
    return bj_groupRandomCurrentPick
endfunction


Specifically, this line:

JASS:
    call ForGroup(whichGroup, function GroupPickRandomUnitEnum)


This system mass orders EVERY unit in the entire map. Why doesn't it just group all the units within X of each selected unit, (and recursively continue to group units until there are no more units left not already in the group), so that you can have specific groups of units do this?

Trigger:
  • Set MUO_Temp_Group = (Units currently selected by (Triggering player))
    • Set MUO_Temp_Unit = (Random unit from MUO_Temp_Group)

What are you going to do if a person selects a bunch of different types of units? If a person selects 1 footman and 11 priests, and the trigger randoms to footman, it's going to mass order all the footmen in the map.

I'm going to graveyard this until these problems are either well documented or fixed.
 

Tru_Power22

You can change this now in User CP.
Reaction score
144
Ok, I documented the issues, I'm going to see if I can fix the other problems.
 

Azlier

Old World Ghost
Reaction score
461
Using null in group enumerations doesn't leak anymore. Patch 1.24c saw to that.
 

Sickle

New Member
Reaction score
13
No. Your system still leaks a group. Azlier did not say that all of the leaks here were fixed.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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 The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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