Hello all, long time dabbler first time forum poster here, I have a question for finding a variable for trigger use. I have a funny asymmetric melee style map I'm making with different spawn locations with unique base mechanics.
I need to find the player who spawned at each base for trigger purposes. I have very dodgy methods at the moment, like detecting initial worker movement, but that wont work for some of the funnier bases without mineral patches (other means of income). The locations are assigned randomly, so lobby things will not work
How do I get the player (or none) that spawned at a particular Start Location?
When you think something like this, you must create a variable as a table (a matrix with 1 dimension). I called it "PlayerStartLocations".
What you may know is that Start Locations are a certain type of points.
Events Game - Map initialization
Local variables i = 0 <Integer> radius = 10 <Integer(Constant)> points = No Point <Point> groups = (Empty unit group) <Unit Group>
Actions General - Action Group: "init points" Actions Variable - Set points = Start location 001 Variable - Set points = Start location 002 Variable - Set points = Start location 003 Variable - Set points = Start location 004 General - For each integer i from 1 to 4 with increment 1, do (Actions) Actions Unit Group - Add all units in (Any units in (Region(points[i], radius)) owned by player Any Player matching Excludes : Dead, Hidden, Missile, with at most Any Amount) to groups[i] General - If (Conditions) then do (Actions) else do (Actions) If (Number of Living units in groups[i]) > 0 Then Variable - Set PlayerStartLocations[i] = (Owner of (Random Living unit from groups[i])) Else
To explain what this does :
- For each points (= start locations), find any units around the point within 10 squares.
- If the unit group has at least 1 unit, we get the unit to retrieve its owner.