HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Simplifing Trigger Work

12-12-2004, 07:16 PM#1
pappi.chullo
The idea is to have a multiboard that displays the map as a grid, and a color for whomever has the most units on the "lot". The only way I found to do it is through 81 triggers, one for each lot. Is there any easier way to do it?

This is the grid. (9x9)


+--+--+--+--+--+--+--+--+--+
|91|92|93|94|95|96|97|98|99|
+--+--+--+--+--+--+--+--+--+
|81|82|83|84|85|86|87|88|89|
+--+--+--+--+--+--+--+--+--+
|71|72|73|74|75|76|77|78|79|
+--+--+--+--+--+--+--+--+--+
|61|62|63|64|65|66|67|68|69|
+--+--+--+--+--+--+--+--+--+
|51|52|53|54|55|56|57|58|59|
+--+--+--+--+--+--+--+--+--+
|41|42|43|44|45|46|47|48|49|
+--+--+--+--+--+--+--+--+--+
|31|32|33|34|35|36|37|38|39|
+--+--+--+--+--+--+--+--+--+
|21|22|23|24|25|26|27|28|29|
+--+--+--+--+--+--+--+--+--+
|11|12|13|14|15|16|17|18|19|
+--+--+--+--+--+--+--+--+--+
12-12-2004, 07:40 PM#2
Kalvorod
Well, no. Each area on the grid is independant from the next, and therefore needs an independant trigger.

That's really all there is to it. Just copy paste it and change the Region# and the position on the multiboard. There is really nothing you can do other then scrap it.
12-13-2004, 12:02 AM#3
Klownkiller
I need a little more info. This is what i think you are wanting to do. You want to check 81 regions and check who has the mostunits in thate area. Because you can do most of it with one trigger if you use an array.
12-13-2004, 01:47 AM#4
th15
Code:
Event:
Whatever

Actions:
For each integer 11-99 do:
      <use your triggers for counting who has the most units, but when refering to a region, use Region[integer A]>
     Multiboard- set value of column <integer A modulus 10> row <integer A divided by 10> to <whatever colour of player who owns sector>

The thing about that is that you still need an init trigger that assigns each region to the variable array Region[11] all the way to Region[99] (yes thats 88 lines of code).
12-13-2004, 02:42 AM#5
pappi.chullo
Instead of replying, I figured just to edit the message.

What would be a way to dispute a tie-breaker, setting the color of the zone to black? My failed trigger is in the attachement.
12-13-2004, 09:07 AM#6
th15
Well if you really need everything, you trigger could look something like this:
Code:
Event:
Every 1 second

Action:
For each integer (A) 11-99 do:
      Pick every unit in Sector[For Loop Integer A] and do:
             Set UnitCount[Player number of picked unit] = UnitCount[Player number of picked unit] + 1
      Set tempInt = 0
      Set tempPlayer = null
      For each integer (B) 1-8 do:
             If UnitCount[For loop Integer B] Greater than tempInt
             Then:
                    Set tempInt = UnitCount[For loop Integer B]
                    Set tempPlayer = Convert player index [For loop Integer B] to player
             Else:
                     If UnitCount[For loop Intger B] equal to tempInt
                     Then:
                           Set tempPlayer = null
                     Else:
                           Do nothing
             Set UnitCount[For loop Integer B] = 0 
      <Code for changing the sector on the multiboard to the desired colour goes here, the variable tempPlayer holds the player who had the most units in the sector>

This trigger uses the original loop to go through each of your regions quickly. For each region it runs a further "nested loop" (note: you must use For loop integer B or you'll get problems) to go through all the players and check which player has the most units. The way my trigger works, any sector that has a tie in the number of units is treated as though no one owns it.
12-13-2004, 11:34 PM#7
pappi.chullo
Quote:
Set tempPlayer = null
What is null?
12-14-2004, 05:37 AM#8
th15
null is the default value of a variable when you haven't assigned it a value. I set it to null so that the sector will not have it's ownership changed, but how you apply this trigger depends a lot of how you do the colours for the multiboard itself, i've just given you thwe framework for accessing each cell and picking units in each region.
12-14-2004, 06:13 AM#9
Guest
NULL = NOTHING

NULL is not zero (0)

th15, you are cool.....!

But why do you guys need a region-counter?
12-14-2004, 05:01 PM#10
Guest
This will leak like hell if the trigger is used often.
If will suggest that you don't use it, but there is certainly a way to bring the leak down.
12-14-2004, 05:30 PM#11
th15
Shrug, there's only two handles in my code, tempplayer and the unit group generated. If i coded every single last line for anyone asking for help i might as well just do everything for everyone.
12-14-2004, 08:48 PM#12
Guest
Yeah but they are used 88 times pr second because of the loop.
12-15-2004, 12:29 AM#13
th15
In the larger scale of things, thats not really that bad. Most of the trigger works with primitives. We're not actually modifying the units that are picked, that would probably cause noticeable lag. In my experience, picking units doesn't really take up a lot of CPU cycles, its only if we need to change a lot of values (i.e. move stuff) that the computer has to struggle update everything instantaneously.

But if there really is trouble with this trigger, the way to fix it is to spread the loop out into a waited loop. Instead of using the for-loop functions, we can use a set of variables to make the entire trigger a loop (i.e. set variable i = i + 1, do if i < 100, wait, run this trigger). That way all the actions would be staggered. That's how I'm doing invisible turret units nowawadays (rather than moving 60+ units around very half second, now it only moves a few every 0.25 seconds).
12-15-2004, 05:17 AM#14
pappi.chullo
Code:
Board Update
    Events
        Unit - A unit enters (Playable map area)
    Conditions
        ((Entering unit) is A structure) Equal to True
    Actions
        For each (Integer A) from 11 to 99, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 1 (Red))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 2 (Blue)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 1 (Red))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 3 (Teal)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 1 (Red))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 4 (Purple)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 1 (Red))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 5 (Yellow)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 1 (Red))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 6 (Orange)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 1 (Red))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 7 (Green)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 1 (Red))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 8 (Pink)))
                    Then - Actions
                        Multiboard - Set the icon for multiboard item in column ((Integer A) mod 10), row ((Integer A) / 10) to Textures\red.blp
                    Else - Actions
                        Do nothing
                -------- / --------
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 2 (Blue))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 1 (Red)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 2 (Blue))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 3 (Teal)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 2 (Blue))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 4 (Purple)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 2 (Blue))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 5 (Yellow)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 2 (Blue))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 6 (Orange)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 2 (Blue))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 7 (Green)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 2 (Blue))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 8 (Pink)))
                    Then - Actions
                        Multiboard - Set the icon for multiboard item in column ((Integer A) mod 10), row ((Integer A) / 10) to Textures\blue.blp
                    Else - Actions
                        Do nothing
                -------- / --------
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 3 (Teal))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 1 (Red)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 3 (Teal))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 2 (Blue)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 3 (Teal))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 4 (Purple)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 3 (Teal))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 5 (Yellow)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 3 (Teal))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 6 (Orange)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 3 (Teal))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 7 (Green)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 3 (Teal))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 8 (Pink)))
                    Then - Actions
                        Multiboard - Set the icon for multiboard item in column ((Integer A) mod 10), row ((Integer A) / 10) to Textures\teal.blp
                    Else - Actions
                        Do nothing
                -------- / --------
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 4 (Purple))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 1 (Red)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 4 (Purple))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 2 (Blue)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 4 (Purple))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 3 (Teal)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 4 (Purple))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 5 (Yellow)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 4 (Purple))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 6 (Orange)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 4 (Purple))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 7 (Green)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 4 (Purple))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 8 (Pink)))
                    Then - Actions
                        Multiboard - Set the icon for multiboard item in column ((Integer A) mod 10), row ((Integer A) / 10) to Textures\purple.blp
                    Else - Actions
                        Do nothing
                -------- / --------
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 5 (Yellow))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 1 (Red)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 5 (Yellow))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 2 (Blue)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 5 (Yellow))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 3 (Teal)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 5 (Yellow))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 4 (Purple)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 5 (Yellow))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 6 (Orange)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 5 (Yellow))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 7 (Green)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 5 (Yellow))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 8 (Pink)))
                    Then - Actions
                        Multiboard - Set the icon for multiboard item in column ((Integer A) mod 10), row ((Integer A) / 10) to Textures\yellow.blp
                    Else - Actions
                        Do nothing
                -------- / --------
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 6 (Orange))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 1 (Red)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 6 (Orange))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 2 (Blue)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 6 (Orange))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 3 (Teal)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 6 (Orange))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 4 (Purple)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 6 (Orange))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 5 (Yellow)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 6 (Orange))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 7 (Green)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 6 (Orange))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 8 (Pink)))
                    Then - Actions
                        Multiboard - Set the icon for multiboard item in column ((Integer A) mod 10), row ((Integer A) / 10) to Textures\orange.blp
                    Else - Actions
                        Do nothing
                -------- / --------
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 7 (Green))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 1 (Red)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 7 (Green))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 2 (Blue)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 7 (Green))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 3 (Teal)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 7 (Green))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 4 (Purple)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 7 (Green))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 5 (Yellow)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 7 (Green))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 6 (Orange)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 7 (Green))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 8 (Pink)))
                    Then - Actions
                        Multiboard - Set the icon for multiboard item in column ((Integer A) mod 10), row ((Integer A) / 10) to Textures\green.blp
                    Else - Actions
                        Do nothing
                -------- / --------
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 8 (Pink))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 1 (Red)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 8 (Pink))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 2 (Blue)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 8 (Pink))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 3 (Teal)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 8 (Pink))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 4 (Purple)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 8 (Pink))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 5 (Yellow)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 8 (Pink))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 6 (Orange)))
                                (Number of units in (Units in player_board[(Integer A)] owned by Player 8 (Pink))) Greater than (Number of units in (Units in player_board[(Integer A)] owned by Player 7 (Green)))
                    Then - Actions
                        Multiboard - Set the icon for multiboard item in column ((Integer A) mod 10), row ((Integer A) / 10) to Textures\pink.blp
                    Else - Actions
                        Do nothing
                -------- / --------


Sigh when I tested it with regular units, it counted alive units and non-structures as well. I have to re-do all the conditions for the specifics. :\
12-15-2004, 11:24 PM#15
pappi.chullo
Code:
For each (Integer A) from 11 to 99, do (Actions)
    Loop - Actions
        For each (Integer B) from 2 to 8, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Number of units in (Units in player_board[(Integer A)] matching ((((Matching unit) is A structure) Equal to True) and ((((Matching unit) is alive) Equal to True) and ((Owner of (Matching unit)) Equal to Player 1 (Red)))))) Greater than (Number of units in (Units in player_board[(Integer A)] matching ((((Matching unit) is A structure) Equal to True) and ((((Matching unit) is alive) Equal to True) or ((Owner of (Matching unit)) Equal to (Player((Integer B))))))))
                    Then - Actions
                        Multiboard - Set the icon for multiboard item in column ((Integer A) mod 10), row ((Integer A) / 10) to Textures\red.blp
                    Else - Actions
                        Do nothing

This is more specific than the old trigger, it bugged if there were dead units or non-structures. Anywho, would this trigger work properly if all the players were set to Integer B inside the Integer A loop?