[Trigger] IS regions buggy?

Status
Not open for further replies.
Level 6
Joined
Dec 8, 2016
Messages
127
Just a simple trigger for my rts map that i want to remove certain destructibles if player doesnt start at that location, & I am sure that regions are in correct position, but why the result just seem strange, it doesnt correctly remove destrutibles, sometimes it does, sometimes doesnt.

Nevermind the leaks, i just testing.


  • Beginning townhall
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set PlayerLoc = ((Picked player) start location)
          • Unit - Create 1 Village Hall First real for (Picked player) at PlayerLoc facing Default building facing degrees
          • -------- Below for "income daily effect" --------
          • Set TownHallFirst[1] = (Last created unit)
          • Unit Group - Add TownHallFirst[1] to TownhallDetect
          • -------- Below for "Building damage effect" --------
          • Unit Group - Add TownHallFirst[1] to BuidingSmoke
          • Unit - Create 1 Child for (Picked player) at (PlayerLoc offset by 400.00 towards ((Angle from PlayerLoc to CenterMap) - 30.00) degrees) facing (Angle from PlayerLoc to CenterMap) degrees
          • Unit - Create 1 Lumberjack for (Picked player) at (PlayerLoc offset by 400.00 towards ((Angle from PlayerLoc to CenterMap) - 15.00) degrees) facing (Angle from PlayerLoc to CenterMap) degrees
          • Unit - Create 1 Woman (Female) for (Picked player) at (PlayerLoc offset by 400.00 towards (Angle from PlayerLoc to CenterMap) degrees) facing (Angle from PlayerLoc to CenterMap) degrees
          • Unit - Create 1 Child (2) for (Picked player) at (PlayerLoc offset by 400.00 towards ((Angle from PlayerLoc to CenterMap) + 15.00) degrees) facing (Angle from PlayerLoc to CenterMap) degrees
          • Camera - Set (Picked player)'s camera Distance to target to 2400.00 over 0.00 seconds
          • Custom script: call RemoveLocation (udg_PlayerLoc)
      • Trigger - Turn on New units appear <gen>
      • Trigger - Turn on Camera view restore Copy 3 <gen>
      • Unit Group - Pick every unit in BuidingSmoke and do (Actions)
        • Loop - Actions
          • Set TownHallFirst[5] = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Start 1 <gen> contains TownHallFirst[5]) Equal to False
            • Then - Actions
              • Set TownStart[1] = (TownStart[1] + 1)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Start 2 <gen> contains TownHallFirst[5]) Equal to False
            • Then - Actions
              • Set TownStart[2] = (TownStart[2] + 1)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Start 3 <gen> contains TownHallFirst[5]) Equal to False
            • Then - Actions
              • Set TownStart[3] = (TownStart[3] + 1)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Start 4 <gen> contains TownHallFirst[5]) Equal to False
            • Then - Actions
              • Set TownStart[4] = (TownStart[4] + 1)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Start 5 <gen> contains TownHallFirst[5]) Equal to False
            • Then - Actions
              • Set TownStart[5] = (TownStart[5] + 1)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Start 6 <gen> contains TownHallFirst[5]) Equal to False
            • Then - Actions
              • Set TownStart[6] = (TownStart[6] + 1)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Start 7 <gen> contains TownHallFirst[5]) Equal to False
            • Then - Actions
              • Set TownStart[7] = (TownStart[7] + 1)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Start 8 <gen> contains TownHallFirst[5]) Equal to False
            • Then - Actions
              • Set TownStart[8] = (TownStart[8] + 1)
            • Else - Actions
      • Set TownStart[20] = (Number of units in BuidingSmoke)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TownStart[1] Equal to TownStart[20]
        • Then - Actions
          • Game - Display to (All players) the text: start 1
          • Destructible - Pick every destructible in Test castle 1 <gen> and do (Actions)
            • Loop - Actions
              • Set Wall[1] = (Picked destructible)
              • Destructible - Remove Wall[1]
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TownStart[2] Equal to TownStart[20]
        • Then - Actions
          • Game - Display to (All players) the text: start 2
          • Destructible - Pick every destructible in Test castle 2 <gen> and do (Actions)
            • Loop - Actions
              • Set Wall[2] = (Picked destructible)
              • Destructible - Remove Wall[2]
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TownStart[3] Equal to TownStart[20]
        • Then - Actions
          • Game - Display to (All players) the text: start 3
          • Destructible - Pick every destructible in Test castle 3 <gen> and do (Actions)
            • Loop - Actions
              • Set Wall[3] = (Picked destructible)
              • Destructible - Remove Wall[3]
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TownStart[4] Equal to TownStart[20]
        • Then - Actions
          • Game - Display to (All players) the text: start 4
          • Destructible - Pick every destructible in Test castle 4 <gen> and do (Actions)
            • Loop - Actions
              • Set Wall[4] = (Picked destructible)
              • Destructible - Remove Wall[4]
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TownStart[5] Equal to TownStart[20]
        • Then - Actions
          • Game - Display to (All players) the text: start 5
          • Destructible - Pick every destructible in Test castle 5 <gen> and do (Actions)
            • Loop - Actions
              • Set Wall[5] = (Picked destructible)
              • Destructible - Remove Wall[5]
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TownStart[6] Equal to TownStart[20]
        • Then - Actions
          • Game - Display to (All players) the text: start 6
          • Destructible - Pick every destructible in Test castle 6 <gen> and do (Actions)
            • Loop - Actions
              • Set Wall[6] = (Picked destructible)
              • Destructible - Remove Wall[6]
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TownStart[7] Equal to TownStart[20]
        • Then - Actions
          • Game - Display to (All players) the text: start 7
          • Destructible - Pick every destructible in Test castle 7 <gen> and do (Actions)
            • Loop - Actions
              • Set Wall[7] = (Picked destructible)
              • Destructible - Remove Wall[7]
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TownStart[8] Equal to TownStart[20]
        • Then - Actions
          • Game - Display to (All players) the text: start 8
          • Destructible - Pick every destructible in Test castle 8 <gen> and do (Actions)
            • Loop - Actions
              • Set Wall[8] = (Picked destructible)
              • Destructible - Remove Wall[8]
        • Else - Actions
  • [trigger]
  • [hidden]
 
Level 25
Joined
May 11, 2007
Messages
4,650
These random numbers you use for the arrays make my head become confused.

Why pick every destructible and then set each picked destructible into a variable only to remove the destructible?
Why not just remove the destructible without making it into a variable?

Don't recycle variables, instead use variables for one thing and then create a new one, reading this:
TownStart[3] Equal to TownStart[20]

What does that say if we just look at it?
Change it to something like:
PlayerStart[For loop A] Equal to RegionTownHall[1]
 
Level 6
Joined
Dec 8, 2016
Messages
127
There are 8 starting locations so it is not random.
Nevermind the efficiency, I am just wondering why this trigger doesnt work.
1) Whats wrong with recycling integer variables? It doesnt work? I have to create around 20 variables without arrays for this trigger?
2) You mean putting destructible into variable doesnt work? So i just "remove picked destructible" ?
3) Do i need to set regions into variable
 
Level 25
Joined
May 11, 2007
Messages
4,650
Whats wrong with recycling integer variables? It doesnt work? I have to create around 20 variables without arrays for this trigger?
No you can still use arrays.
What I mean is to make more use of proper names that makes the code more readable,
and have variables only do one thing rather than having an array do multiple things where a number chooses what the variable means.

You mean putting destructible into variable doesnt work? So i just "remove picked destructible"
It does work, but you don't have any reason to do it, just remove the picked destructible.

Do i need to set regions into variable
You don't have to, but you could loop through them that way with an array, so it would be easier.
 
Level 6
Joined
Dec 8, 2016
Messages
127
Whats wrong with recycling integer variables? It doesnt work? I have to create around 20 variables without arrays for this trigger?
No you can still use arrays.
What I mean is to make more use of proper names that makes the code more readable,
and have variables only do one thing rather than having an array do multiple things where a number chooses what the variable means.

You mean putting destructible into variable doesnt work? So i just "remove picked destructible"
It does work, but you don't have any reason to do it, just remove the picked destructible.

Do i need to set regions into variable
You don't have to, but you could loop through them that way with an array, so it would be easier.

Thanks for reply, will consider that, but what i am looking for isn't efficiency. The problem is that the trigger i posted doesn't work.
When i test the map, the trigger sometimes can detect, sometimes cant.

I would aprreciate if someone can make a test map that works, doesnt matter if it leaks or doesnt have loop etc, for this action.. thanks

My map is similar to warcraft 3 rts where your starting location isnt fixed,
there are 8 locations in this map, each location has special destructibles.
If the location is vacant (eg. maybe only 2 players play this game),
I want the destructible of that vacant location to be removed.
 
Level 6
Joined
Dec 8, 2016
Messages
127
  • For each (Integer A) from 1 to 8, do (Actions)
    • Loop - Actions
      • Set TownHallGroup = (Units in TownRe[(Integer A)] matching ((Unit-type of (Matching unit)) Equal to Village Hall First real))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TownHallGroup) Equal to 0
        • Then - Actions
          • Game - Display to (All players) the text: (Start + (String((Integer A))))
          • Destructible - Pick every destructible in TownRe_wall[(Integer A)] and do (Actions)
            • Loop - Actions
              • Set Wall[(Integer A)] = (Picked destructible)
              • Destructible - Remove Wall[(Integer A)]
        • Else - Actions
      • Custom script: call DestroyGroup (udg_TownHallGroup)
Nevermind, i discovered that putting regions into variable and detecting through group works. Thanks for helping
 
Status
Not open for further replies.
Top