Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // UnitCreateMultiple creates units of multiple types and quantities and returns a unitgroup containing
- // the created units. The format for the unitTypes parameter string is:
- // "unittype,quantity unittype,quantity" assuming the default controlChar is ","
- // An example of use is:
- // "Marine,5 Zealot,3 DudeBro,1"
- unitgroup UnitCreateMultiple (string unitTypes, int createStyle, int player, point position, fixed face)
- {
- string controlChar = ",";
- string space = " ";
- unitgroup g = UnitGroupEmpty();
- int i = 1;
- string word = StringWord(unitTypes,i);
- while (word != null)
- {
- // replace the word's controlChar with a space
- word = StringReplaceWord(word,controlChar,space,c_stringReplaceAll,false);
- // Create units and add them to the unitgroup g
- UnitGroupAddUnitGroup(g,UnitCreate(StringToInt(StringWord(word,2)),StringWord(word,1),createStyle,player,position,face));
- // increment i and set the next word
- i+=1;
- word = StringWord(unitTypes,i);
- }
- return g;
- }
Advertisement
Add Comment
Please, Sign In to add comment