I'm trying to make trigger that selects every 2 minutes 1 Tanker Truck and moves it to target location. How to make that "select 1 random Tanker Truck" of this trigger?
This trigger doesn't send truly random truck. I tested 5 times and every time trucks are sent in same order. As Kueken531 saied this isn't selecting "truly random" unit.
I'm trying to make trigger that selects every 2 minutes 1 Tanker Truck and moves it to target location. How to make that "select 1 random Tanker Truck" of this trigger?
Select all tanker Trucks, store them to a unit group. Then select one random unit from that group.
You can also set the limit for the group to 1 unit initially, but then you probably won't get a truly random unit.
I made 2 triggers:
"Send random truck" trigger can select also a truck that is already moving to a beacon. How to prevent that?
I have 20 trucks at base and idea is to select trucks 1 by 1 and send them a beacon.
How to remove that selected random unit from unit group?
do it like this:
variable u - unit
set u = random unit from tanker trucks
order u to move...
remove u from tanker trucks group
This works quite good. Triggers:
This trigger doesn't send truly random truck. I tested 5 times and every time trucks are sent in same order. As Kueken531 saied this isn't selecting "truly random" unit.
@Terhonator: Go
Click File > Preferences > Test Document: Make sure "Use fixed random seed" is unchecked
It's not what Kueken531 meant.
Also your UNIT variable should be local for sake of logic unless you use that variable reference in other trigger.
I changed the variable to "local" variable and now it sends truly random truck each time.
First time actually when I see any diffrence between local and non-local variable.
Solved. Thanks everyone.
I doubt that's the reason really. It's just different place in memory. The Random function is what decides which unit is it.