That code would run for 10 seconds and make all the units run away from eachother for ten seconds to a maximum distance of 2. So they would spread out without scattering.
There are better ways you could do it but that's probably the easiest
That's great! I didn't know the exact function names or syntax off the top of my head but I'm glad you were able to follow it and implement your own.
If you can, upload a clip to youtube. I love watching that kind of stuff where units make a descission individually and yet it results in group organization.
EDIT: you said it works, but i realized a small mistake i made. instead of "others = g" i meant to put others = copyofunitgroup(g). theres some function which makes a copy of a group whereas i think "=" just passes a reference to the same group
Looking for auto-splitting behavior or trigger. As performance friendly as possible.
Maybe ask this dude.
There is no trigger to make units split but it is not very hard to create one.
The easiest way would be to add all the units to a unit group and do something like this:
That code would run for 10 seconds and make all the units run away from eachother for ten seconds to a maximum distance of 2. So they would spread out without scattering.
There are better ways you could do it but that's probably the easiest
@finiteturtles: Go
Thank you, how do I convert this code to trigger?
Nevermind, made my own and it works just as i need.
That's great! I didn't know the exact function names or syntax off the top of my head but I'm glad you were able to follow it and implement your own.
If you can, upload a clip to youtube. I love watching that kind of stuff where units make a descission individually and yet it results in group organization.
EDIT: you said it works, but i realized a small mistake i made. instead of "others = g" i meant to put others = copyofunitgroup(g). theres some function which makes a copy of a group whereas i think "=" just passes a reference to the same group
@finiteturtles: Go
No i made totally mine from scratch. Can't upload, too long but i can give you the trigger:
splitting Events TriggerAddEventChatMessage(c_playerAny, "split", true) Local Variables splitUnitNumber1 = 0 <int> splitUnitGroup2 = (UnitGroupEmpty()) <unitgroup> splitUnit2 = null <unit> splitNumberOfUnitsInGroup1 = 0 <int> splitUnit1 = null <unit> splitUnitGroup1 = (UnitGroupEmpty()) <unitgroup> Conditions Actions SetVariable(splitUnitGroup1, (UnitGroupSelected((EventPlayer())))) SetVariable(splitNumberOfUnitsInGroup1, (UnitGroupCount(splitUnitGroup1, c_unitCountAlive))) IfThenElse() if Comparison(splitNumberOfUnitsInGroup1, <, 10) then SetVariable(splitUnitNumber1, 5) else IfThenElse() if And() cond Comparison(splitNumberOfUnitsInGroup1, >, 10) Comparison(splitNumberOfUnitsInGroup1, <, 25) then SetVariable(splitUnitNumber1, 10) else IfThenElse() if And() cond Comparison(splitNumberOfUnitsInGroup1, >, 25) Comparison(splitNumberOfUnitsInGroup1, <, 90) then SetVariable(splitUnitNumber1, 20) else IfThenElse() if And() cond Comparison(splitNumberOfUnitsInGroup1, >, 90) Comparison(splitNumberOfUnitsInGroup1, <, 200) then SetVariable(splitUnitNumber1, 35) else IfThenElse() if Comparison(splitNumberOfUnitsInGroup1, >, 200) then SetVariable(splitUnitNumber1, 50) else Repeat(splitUnitNumber1) actions SetVariable(splitUnitGroup1, (UnitGroupSelected((EventPlayer())))) Repeat(splitNumberOfUnitsInGroup1) actions IfThenElse() if Comparison(splitNumberOfUnitsInGroup1, >, 1) then SetVariable(splitUnit1, (UnitGroupRandomUnit(splitUnitGroup1, c_unitCountAlive))) SetVariable(splitUnitGroup2, splitUnitGroup1) UnitGroupRemove(splitUnitGroup2, splitUnit1) SetVariable(splitUnit2, (UnitGroupClosestToPoint(splitUnitGroup2, (UnitGetPosition(splitUnit1))))) IfThenElse() if Comparison((DistanceBetweenPoints((UnitGetPosition(splitUnit1)), (UnitGetPosition(splitUnit2)))), <, 2.0) then UnitIssueOrder(splitUnit1, (OrderTargetingPoint("move", 0, (PointOffsetTowardsPoint((UnitGetPosition(splitUnit1)), -2.0, (UnitGetPosition(splitUnit2)))))), c_orderQueueReplace) else UnitIssueOrder(splitUnit1, (Order("stop", 0)), c_orderQueueReplace) UnitGroupRemove(splitUnitGroup1, splitUnit1) else UnitIssueOrder(splitUnit1, (Order("stop", 0)), c_orderQueueReplace) Wait(0.1, c_timeReal) UnitIssueOrder(splitUnit1, (Order("stop", 0)), c_orderQueueReplace)
There is not too much to look at, units move chaoticly but it does the job of making space they take bigger.
@ZenonMalinowski: Go
you have to use the "markup type" button and put your code inside these tags