Weird problem on unit count

Status
Not open for further replies.
Level 5
Joined
Jun 12, 2018
Messages
149
Hi ! I'm trying to develop a generic spawning/moving system over 20 regions.
I have 3 static points over these zones so I only need 3 triggers to handle everything.
The thing is I need to spawn dummies for each player over these points to identify the zones, my trigger will look like this :

  • Spawn to Waypoint
    • Events
      • Unit - A unit enters Player1Spawn <gen>
      • Unit - A unit enters Player2Spawn <gen>
      • Unit - A unit enters Player3Spawn <gen>
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Owner of (Entering unit)) Equal to TEAM_1_IA_PLAYER
          • (Owner of (Entering unit)) Equal to TEAM_2_IA_PLAYER
    • Actions
      • Set tempSpawnLocation = (Position of (Entering unit))
      • Set uCheckPointDummy = (Units within 300.00 of tempSpawnLocation matching ((Unit-type of (Matching unit)) Equal to dummyCheckpoint))
      • Game - Display to (All players) the text: (String((Number of units in uCheckPointDummy)))
      • Custom script: call RemoveLocation(udg_tempSpawnLocation)
      • Set tempSpawn2Location = PLAYER_WAYPOINTS[(Player number of (Owner of (Random unit from uCheckPointDummy)))]
      • Custom script: call DestroyGroup(udg_uCheckPointDummy)
      • Unit - Order (Entering unit) to Move To tempSpawn2Location
      • Custom script: call RemoveLocation(udg_tempSpawn2Location)
The dummies I'm using to locate the player region are created here (I can see them on the region!):

  • Player Dummy Points
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • For each (Integer B) from 1 to 20, do (Actions)
        • Loop - Actions
          • Unit - Create 1 dummyCheckpoint for (Player((Integer B))) at PLAYER_SPAWN_POINT[(Integer B)] facing Default building facing degrees
          • Unit - Create 1 dummyCheckpoint for (Player((Integer B))) at PLAYER_LEAVE_POINT[(Integer B)] facing Default building facing degrees
          • Unit - Create 1 dummyCheckpoint for (Player((Integer B))) at PLAYER_WAYPOINTS[(Integer B)] facing Default building facing degrees
      • Wait 2.00 seconds
      • Game - Display to (All players) the text: (String((Number of units in (Units in P1Zone <gen> matching ((Unit-type of (Matching unit)) Equal to dummyCheckpoint)))))
      • Game - Display to (All players) the text: (String((Number of units in (Units in Player1Waypoint <gen> matching ((Unit-type of (Matching unit)) Equal to dummyCheckpoint)))))
This seems to be a simple spawning trigger BUT I'm always getting a "0" when displaying the number of units matching the dummy type so my triggers won't work.
"P1Zone" above contains the 3 locations (SPAWN, WAYPOINT, LEAVE) so I should get 3 on this request :

  • Game - Display to (All players) the text: (String((Number of units in (Units in P1Zone <gen> matching ((Unit-type of (Matching unit)) Equal to dummyCheckpoint)))))
As I said I can see those dummies in my player region and I'm sure of the unit-type.

Question is : who's the most high between me and my world editor ?
 
Last edited:
Level 13
Joined
May 10, 2009
Messages
868
Only "GroupEnumUnitsOfPlayer()" and "GroupEnumUnitsOfType()" are capable of detecting units with Locust ability. Try to add those dummies to a specific unit group when they are created, and check if they are close to one of those regions.
 
Level 5
Joined
Jun 12, 2018
Messages
149
@BloodSoul I've tried your solution but it doesn't work either, I'm posting the changed code below.

  • Player Dummy Points
    • Events
    • Conditions
    • Actions
      • For each (Integer B) from 1 to 20, do (Actions)
        • Loop - Actions
          • Unit - Create 1 dummyCheckpoint for (Player((Integer B))) at PLAYER_SPAWN_POINT[(Integer B)] facing Default building facing degrees
          • Unit Group - Add (Last created unit) to ugDummiesLocation[(Integer B)]
          • Unit - Create 1 dummyCheckpoint for (Player((Integer B))) at PLAYER_LEAVE_POINT[(Integer B)] facing Default building facing degrees
          • Unit Group - Add (Last created unit) to ugDummiesLocation[(Integer B)]
          • Unit - Create 1 dummyCheckpoint for (Player((Integer B))) at PLAYER_WAYPOINTS[(Integer B)] facing Default building facing degrees
          • Unit Group - Add (Last created unit) to ugDummiesLocation[(Integer B)]
  • Spawn to Waypoint
    • Events
      • Unit - A unit enters Player1Spawn <gen>
      • Unit - A unit enters Player2Spawn <gen>
      • Unit - A unit enters Player3Spawn <gen>
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Owner of (Entering unit)) Equal to TEAM_1_IA_PLAYER
          • (Owner of (Entering unit)) Equal to TEAM_2_IA_PLAYER
    • Actions
      • Set tempSpawnLocation = (Position of (Entering unit))
      • For each (Integer iPlayerNumber) from 1 to 20, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in (Units within 200.00 of tempSpawnLocation matching (((Matching unit) is in ugDummiesLocation[iPlayerNumber]) Equal to True))) Greater than 0
            • Then - Actions
              • Set iCurrentPlayer = iPlayerNumber
              • Game - Display to (All players) the text: (String(iPlayerNumber))
              • Set iPlayerNumber = 21
            • Else - Actions
      • Custom script: call RemoveLocation(udg_tempSpawnLocation)
      • Set tempSpawn2Location = PLAYER_WAYPOINTS[iCurrentPlayer]
      • Unit - Order (Entering unit) to Move To tempSpawn2Location
      • Custom script: call RemoveLocation(udg_tempSpawn2Location)
The trigger is fired but I will never have my display message shown up in game so it doesn't work that way, can you see what I'm missing ?
Do you have a more elegant solution ?

EDIT : This kind of trigger is a pain in the ass using GUI & globals, you can't even use local integer variables in your "For Loops" without using custom script call -_-
 
Last edited:
Status
Not open for further replies.
Top