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)
- Loop - Actions
- Do Multiple ActionsFor each (Integer A) from 1 to 12, do (Actions)
- Events
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
- If - Conditions
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (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 )
- If - Conditions
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
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
- If - Conditions
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Loop - 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)
- Events
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
- If - Conditions
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Loop - 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)
- Events
-------------
Screenshot:
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.