• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

How can i simplify this trigger system! HELP!

Status
Not open for further replies.
Level 11
Joined
Nov 1, 2008
Messages
828
I am trying to make a system for my duel, where once 1v1(1-5) = 2v2(1-5) where i have to have 5 triggers each for 1 = 1, 2 = 2 etc. I would have to do this 100 times basicly for my 7 duels. Is there anyway to simplify this? Other then JASS, i'm not good at that.

Thanks in advanced.






  • Untitled Trigger 012
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Duel_Type[1] Equal to 1
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Duel_Type[2] Equal to 1
            • Then - Actions
              • Set Duel_1v1_to_2v2[1] = (Random integer number between 1 and 2)
              • Wait 0.25 seconds
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Duel_1v1_to_2v2[1] Equal to 1
                • Then - Actions
                  • Set Duel_1v1_to_2v2[1] = 0
                  • Trigger - Run Duel1v1 <gen> (ignoring conditions)
                • Else - Actions
                  • Do nothing
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Duel_1v1_to_2v2[1] Equal to 1
                • Then - Actions
                  • Set Duel_1v1_to_2v2[1] = 0
                  • Trigger - Run Duel2v2 <gen> (ignoring conditions)
                • Else - Actions
                  • Do nothing
            • Else - Actions
              • Do nothing
        • Else - Actions
          • Do nothing
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
I am trying to make a system for my duel, where once 1v1(1-5) = 2v2(1-5) where i have to have 5 triggers each for 1 = 1, 2 = 2 etc. I would have to do this 100 times basicly for my 7 duels. Is there anyway to simplify this? Other then JASS, i'm not good at that.

Thanks in advanced.






  • Untitled Trigger 012
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Duel_Type[1] Equal to 1
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Duel_Type[2] Equal to 1
            • Then - Actions
              • Set Duel_1v1_to_2v2[1] = (Random integer number between 1 and 2)
              • Wait 0.25 seconds
              • !!!!!
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Duel_1v1_to_2v2[1] Equal to 1
                • Then - Actions
                  • Set Duel_1v1_to_2v2[1] = 0
                  • Trigger - Run Duel1v1 <gen> (ignoring conditions)
                • Else - Actions
                  • Do nothing
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Duel_1v1_to_2v2[1] Equal to 1
                • Then - Actions
                  • Set Duel_1v1_to_2v2[1] = 0
                  • Trigger - Run Duel2v2 <gen> (ignoring conditions)
                • Else - Actions
                  • Do nothing
              • !!!!!
            • Else - Actions
              • Do nothing
        • Else - Actions
          • Do nothing
the part with the exclamation marks does exactly the same thing
but how will the second part ever trigger? It's always the first that will be triggered..
since it sets the varialble to 0 which then will not work for the second if.

A trigger doesn't fire every if at the same time :p
Remember triggers will do things from top to bottom..

for your problem, try using loops:
Integer A
Integer B
Integer Variable

It's inside your actions..

look for: For each (Integer A) from ... to ...

then use it as followed:

For each (integer A) from 1 to 10 do
set duel_1v1_to_2v2(Integer A) = 0

(this was just an example of how you can use it)

this will do the following:
first time it goes through the loop:
set duel_1v1_to_2v2(1) = 0
second time:
set duel_1v1_to_2v2(2) = 0
etc...

you can use this instead of recreating 100's of triggers since you can make it go through the index of your array

also: do nothing is useless, it actually does nothing...
why not remove them?

another reminder: using waits can cause problems in your triggers when they are fired within each other.
For example:
  • Untitled Trigger 012
    • Events
      • Every 1 seconds of game
    • Conditions
    • Actions
      • wait 2 seconds
      • set some_variable = some_variable+1
this will cause some trouble with your variable as you can imagine ;)
but I guess it wouldn't make a difference since your running the trigger through an action probably. As long as you don't run them within the same waiting time this will not cause problems.
If it does try using timers instead :)

EDIT: sorry for the bad trigger examples, I don't have the editor open right now...
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,240
Your trigger could be reduced to this:

  • Untitled Trigger 012
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Duel_Type[1] Equal to 1
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Duel_Type[2] Equal to 1
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Random integer number between 1 and 2 Equal to 1
                • Then - Actions
                  • Trigger - Run Duel1v1 <gen> (ignoring conditions)
                • Else - Actions
                  • Trigger - Run Duel2v2 <gen> (ignoring conditions)
            • Else - Actions
        • Else - Actions
You can use
  • For each (Integer A) from 1 to x, do (Actions)
    • Loop - Actions
      • For each (Integer B) from 1 to y, do (Actions)
        • Loop - Actions
like Hashjie mentioned.

Then use A and B for the indexes. Remember not to compare the value with itself. Use A != B condition.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Your trigger could be reduced to this:

  • Untitled Trigger 012
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Duel_Type[1] Equal to 1
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Duel_Type[2] Equal to 1
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Random integer number between 1 and 2 Equal to 1
                • Then - Actions
                  • Trigger - Run Duel1v1 <gen> (ignoring conditions)
                • Else - Actions
                  • Trigger - Run Duel2v2 <gen> (ignoring conditions)
                • Else - Actions
            • Else - Actions
        • Else - Actions
You can use
  • For each (Integer A) from 1 to x, do (Actions)
    • Loop - Actions
      • For each (Integer B) from 1 to y, do (Actions)
        • Loop - Actions
like Hashjie mentioned.

Then use A and B for the indexes. Remember not to compare the value with itself. Use A != B condition.

thnx for the examples :)
I can't open the editor right now because I'm @ work >.>
 
Level 11
Joined
Nov 1, 2008
Messages
828
So how would this work out? I've never really used the "For each (Interger A)" trigger. Does this some how change the indexs to 1 up to 5?

i forgot to mention also, that this system was to prevent a tie happening, such as 2v2 was voted 3 times and 1v1 was voted 3, it would randomize the tied ones.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
So how would this work out? I've never really used the "For each (Interger A)" trigger. Does this some how change the indexs to 1 up to 5?

as I have explained above For each (Integer A) is a loop that continously do the actions untill it has run though a certain amount.
You can referr to that amount using (Integer A) example:

  • For each (Integer A) from 1 to 5, do (Actions)
    • Loop - Actions
      • set some_variable[(Integer A)] = something
this will do the following:
set some_variable[1] = something
set some_variable[2] = something
set some_variable[3] = something
set some_variable[4] = something
set some_variable[5] = something

you can also use multiple loops inside each other as maker has shown.
A little example:

  • For each (Integer A) from 1 to 5, do (Actions)
    • Loop - Actions
      • For each (Integer B) from 6 to 10, do (Actions)
        • Loop - Actions
          • set some_integer[(Integer A)] = (Integer B)
this will do the following:
set some_integer[1] = 6
set some_integer[2] = 7
set some_integer[3] = 8
set some_integer[4] = 9
set some_integer[5] = 10

however Integer A and Integer B are pre-defined global variables of the world editor and can have different values when they are used more then once.

Here's a tutorial:
http://www.hiveworkshop.com/forums/1276157-post1.html

look at the last part:
g. Avoiding the usage of Integer A (or Integer B)

EDIT: u might want to look further into that tutorial since it's quite usefull for beginning GUI users
The tutorial is mainly for spell based triggers but normal triggers also suffer from leaks and uncorrect usage of GUI lines.
 
Last edited:
Status
Not open for further replies.
Top