I’ve done this kind of thing a bunch of times with variations. I don’t know how much you know. If I explain something you don’t understand, ask. Some of the concepts may be advanced for you.
Korval is right on principle. You put the pieces in a deck and deal them out from there. Let’s say you have 4 locations on the map where your units will go: 4 in New York, 3 in Denver, 2 in Cleveland, and 1 in Toledo.
-
Create a prototype for the affected units. In this prototype, add 4 “send-to” commands, one for each target location. For example, one command would be “goToDenver,” and it would say “Main Map” with either the target as a region or as Denver’s (x,y) pixel location. Include this prototype in all the units.
-
Create a deck. Let’s say we call it “RandomUnits.” Put it somewhere innocuous such as (0,0) or off map. Put all your units to be dispersed to those cities in this deck. Set up the deck as “always shuffle,” and set it up as face up and drawn units are face up. (There is no face down here.)
-
Next we need to create a script, and this can be done in a number of ways. One way is to create an action button piece in the middle of your map. When you start a new game, it will appear and say something like “Setup” or “Push me.” It would have the following traits:
3a. Basic piece. Here you insert the image you created for the button. It says “Setup.” Or you can leave it blank. In that case, you need to add a text field trait with text = “setup.” (I haven’t tried this alternate approach.)
3b. Add an action button trait. This trait will do the following command: “Distribute”. The checkbox should not be checked.
3c. Add a trigger trait. The command that causes the trigger to run is “Distribute”. It will do 5 other commands, which are 3D, 3e, …
3D-3g Add 4 global key command traits (GKCs). One will be “send4PiecesToDenver”. The global command it will do is “goToDenver”, which is a trait that the units understand. Omit the context menu field. You specify the location as the deck “RandomUnits.” Down below, you say “fixed number of units” and 3, which is how many will go to Denver. Make duplicate traits for the other cities with their number of units.
3h. In the trigger trait above, add the 4 commands (.e.g send4PiecesToDenver) in any order. Then add a 5th command “deleteMe.”
3i. Add a delete trait to your setup piece Leave the menu field blank. Set the command to execute it to “deleteMe.”
Done. When you press the button, it will send the 4 GKCs to the pieces in the deck, which will cause the proper number of units to go to cities. The delete part will delete the button; you don’t need or want it anymore.
Note I use long text strings for my command strings. I do this because it help self-document what’s happening. If I return to the editor later, I don’t want to see a crap-ton of abbreviations.