1. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  3. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Solved] How Can I reduce the Amount Of triggers?

Discussion in 'Triggers & Scripts' started by SunTzu7387, Jan 20, 2012.

  1. SunTzu7387

    SunTzu7387

    Joined:
    Mar 28, 2009
    Messages:
    66
    Resources:
    0
    Resources:
    0
    I'm Trying to Reduce these triggers since this is way too inefficient can someone help me?
    Ill Give + Rep to anyone who helps me. Thank you in advance.
    This is the first trigger
    • Events
      • Unit - A unit Finishes research
    • Conditions
      • (Researched tech-type) Equal to Spawn Berserker Every 25 Seconds
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 3 (Teal)
        • Then - Actions
          • Trigger - Turn on Spqwn Trigger Copy 2 <gen>
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 2 (Blue)
        • Then - Actions
          • Trigger - Turn on Spqwn Trigger Copy <gen>
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
        • Then - Actions
          • Trigger - Turn on Spqwn Trigger <gen>
        • Else - Actions


    The Trigger Above Turns These Triggers on Down Below

    Spqwn Trigger <gen>
    • Events
      • Time - Every 25.00 seconds of game time
    • Conditions
      • (Orc Warlord 0014 <gen> is alive) Equal to True
    • Actions
      • Set pointy_player1 = (Center of GruntSpawnRed <gen>)
      • Unit - Create 1 Troll Berserker for Player 1 (Red) at pointy_player1 facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_pointy_player1)


    Spqwn Trigger Copy <gen>
    • Events
      • Time - Every 25.00 seconds of game time
    • Conditions
      • (Orc Warlord 0004 <gen> is alive) Equal to True
    • Actions
      • Set pointy_player2 = (Center of GruntSpawnBlue <gen>)
      • Unit - Create 1 Troll Berserker for Player 2 (Blue) at pointy_player2 facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_pointy_player2)


    Spqwn Trigger Copy 2 <gen>
    • Events
      • Time - Every 25.00 seconds of game time
    • Conditions
      • (Orc Warlord 0015 <gen> is alive) Equal to True
    • Actions
      • Set pointy_player3 = (Center of GruntSpawnLightBlue <gen>)
      • Unit - Create 1 Troll Berserker for Player 3 (Teal) at pointy_player3 facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_pointy_player3)
     
    Last edited: Jan 20, 2012
  2. Mr_Bean

    Mr_Bean

    Joined:
    Feb 11, 2011
    Messages:
    1,823
    Resources:
    6
    Maps:
    2
    Spells:
    4
    Resources:
    6
    Don't think there's much you can do. Just a small optimization:

    • Trigger
      • Events
        • Unit - A unit Finishes research
      • Conditions
        • (Researched tech-type) Equal to Iron Forged Swords
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Triggering player) Equal to Player 3 (Teal)
          • Then - Actions
            • Trigger - Turn on SpawnPlayer3
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Triggering player) Equal to Player 2 (Blue)
              • Then - Actions
                • Trigger - Turn on SpawnPlayer2
              • Else - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Triggering player) Equal to Player 1 (Red)
                  • Then - Actions
                    • Trigger - Turn on SpawnPlayer1
                  • Else - Actions


    This way it doesn't have to run each "If" - if the one condition is true, it stops.
     
  3. Marsal

    Marsal

    Joined:
    Jun 24, 2009
    Messages:
    1,345
    Resources:
    15
    Maps:
    1
    Spells:
    14
    Resources:
    15
    Also this.

    • Events
      • Time - Every 25.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Orc Warlord 0014 <gen> is alive) Equal to True
        • Then - Actions
          • Set pointy_player1 = (Center of GruntSpawnRed <gen>)
          • Unit - Create 1 Troll Berserker for Player 1 (Red) at pointy_player1 facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_pointy_player1)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Orc Warlord 0004 <gen> is alive) Equal to True
            • Then - Actions
              • Set pointy_player2 = (Center of GruntSpawnBlue <gen>)
              • Unit - Create 1 Troll Berserker for Player 2 (Blue) at pointy_player2 facing Default building facing degrees
              • Custom script: call RemoveLocation(udg_pointy_player2)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Orc Warlord 0015 <gen> is alive) Equal to True
                • Then - Actions
                  • Set pointy_player3 = (Center of GruntSpawnLightBlue <gen>)
                  • Unit - Create 1 Troll Berserker for Player 3 (Teal) at pointy_player3 facing Default building facing degrees
                  • Custom script: call RemoveLocation(udg_pointy_player3)
                • Else - Actions
     
  4. Mr_Bean

    Mr_Bean

    Joined:
    Feb 11, 2011
    Messages:
    1,823
    Resources:
    6
    Maps:
    2
    Spells:
    4
    Resources:
    6
    He only wants to spawn units for the player that completes the research.
     
  5. Marsal

    Marsal

    Joined:
    Jun 24, 2009
    Messages:
    1,345
    Resources:
    15
    Maps:
    1
    Spells:
    14
    Resources:
    15
    Oh, didn't see that.
    Then it would be easier that after a player researches it, a boolean is changed to true and then the timer trigger would check it.
    Somehow like this:

    • Trigger
    • Events
      • Unit - A unit Finishes research
    • Conditions
      • (Researched tech-type) Equal to Iron Forged Swords
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering player) Equal to Player 3 (Teal)
        • Then - Actions
          • Set - P3_bool=true.
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ......
    • If - Conditions
      • Spawn trigger is on Equal to False
      • Then - Actions
        • Trigger - Turn on Spawn
      • Else - Actions


    • Events
      • Time - Every 25.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Orc Warlord 0014 <gen> is alive) Equal to True
          • P3_bool Equal to True
        • Then - Actions
          • Set pointy_player1 = (Center of GruntSpawnRed <gen>)
          • Unit - Create 1 Troll Berserker for Player 1 (Red) at pointy_player1 facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_pointy_player1)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ......
     
  6. SunTzu7387

    SunTzu7387

    Joined:
    Mar 28, 2009
    Messages:
    66
    Resources:
    0
    Resources:
    0
    ok what time of variable is p3? is it boolean?
     
  7. Mr_Bean

    Mr_Bean

    Joined:
    Feb 11, 2011
    Messages:
    1,823
    Resources:
    6
    Maps:
    2
    Spells:
    4
    Resources:
    6
    Yes. It may be better to make it a boolean array instead of having 1 boolean for each player.
     
  8. Marsal

    Marsal

    Joined:
    Jun 24, 2009
    Messages:
    1,345
    Resources:
    15
    Maps:
    1
    Spells:
    14
    Resources:
    15
    Nope, if there is only 4 player then 4 separate non-array boolean variables are better since it takes up less space.
     
  9. overcold_ice

    overcold_ice

    Joined:
    Apr 30, 2011
    Messages:
    356
    Resources:
    0
    Resources:
    0
    should be like this:
    • Spawn
    • Events
      • Time - Every 25.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Orc Warlord 0014 <gen> is alive) Equal to True
          • pBool [1] Equal to True
        • Then - Actions
          • Set tempPoint = (Center of GruntSpawnRed <gen>)
          • Unit - Create 1 Troll Berserker for Player 1 (Red) at tempPoint facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_tempPoint)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • . . .


    use tempPoint instead of pointy_playerX, since it will not make any difference
    and use boolean array instead . . . "pBool" replace "PX_bool"
     
  10. SunTzu7387

    SunTzu7387

    Joined:
    Mar 28, 2009
    Messages:
    66
    Resources:
    0
    Resources:
    0
    Thanx for the Help I just made it a boolean array nd tested it and it works perfectly. Phew thanx Reduced alot of triggers on my map! Problem solved +rep for all who helped.
     
  11. SanKakU

    SanKakU

    Joined:
    May 11, 2008
    Messages:
    1,183
    Resources:
    1
    Maps:
    1
    Resources:
    1
    learn jass, vjass, and cjass...gui takes 15000 triggers...it's madness.
     
  12. Marsal

    Marsal

    Joined:
    Jun 24, 2009
    Messages:
    1,345
    Resources:
    15
    Maps:
    1
    Spells:
    14
    Resources:
    15
    What´s the reason of arrayed booleans? There are only 4 players.
     
  13. SunTzu7387

    SunTzu7387

    Joined:
    Mar 28, 2009
    Messages:
    66
    Resources:
    0
    Resources:
    0
    I did an example with 4 players there are actually 12 in my map. I just put out that much to simplify it.
     
  14. overcold_ice

    overcold_ice

    Joined:
    Apr 30, 2011
    Messages:
    356
    Resources:
    0
    Resources:
    0
    arrays are better -_-
    you can set it in a loop, with variables, etc . . .
    more flexible . .
     
  15. Marsal

    Marsal

    Joined:
    Jun 24, 2009
    Messages:
    1,345
    Resources:
    15
    Maps:
    1
    Spells:
    14
    Resources:
    15
    You just wrote down the keyword.... IN LOOP.
    In this trigger the arrays are not required. There is no loop and there are only 4 players. Ofc it´s more efficient if you have loops. But since this trigger have no loop, the arrayed variables are less efficient.
     
  16. overcold_ice

    overcold_ice

    Joined:
    Apr 30, 2011
    Messages:
    356
    Resources:
    0
    Resources:
    0
    you forgot the variables part . . . .
    and it's 4 players -_-
    + a 1000 array storage variable are better than 1000 variables
    even a 4 array storage variable are better than 4 variables . . .
    even if you set up those variables manually, without loops or variables . . .

    and it's not less efficient . . . .
    it's more efficient . . .

    example:
    say you have 100 triggers, each one you need 5 unit variables . . .
    then you do what you said (using no array variables)
    result: crazy 500 variables
    if you use my method (array variables)
    you can simplify it to at least 100, if you are lazy . . . .
    or only to 1, if you aren't that lazy . . . .
     
  17. SunTzu7387

    SunTzu7387

    Joined:
    Mar 28, 2009
    Messages:
    66
    Resources:
    0
    Resources:
    0
    Sorry lol gotta master gui first then will move to jass
     
  18. Marsal

    Marsal

    Joined:
    Jun 24, 2009
    Messages:
    1,345
    Resources:
    15
    Maps:
    1
    Spells:
    14
    Resources:
    15
    I see you don´t understand... Dude it´s a common method. These boolean variables are only used for 4 players and only by these triggers.... Only morons use arrayed variables for only 4 thing within only 2 triggers without any complicated calculations or loops... 4 simple variable takes up less space than an arrayed variable... Thats why it´s less efficient in THIS TRIGGER.... Not in the others but in this...
     
  19. Marsal

    Marsal

    Joined:
    Jun 24, 2009
    Messages:
    1,345
    Resources:
    15
    Maps:
    1
    Spells:
    14
    Resources:
    15
    I see you don´t understand... Dude it´s a common method. These boolean variables are only used for 4 players and only by these triggers.... Only morons use arrayed variables for only 4 thing within only 2 triggers without any complicated calculations or loops... 4 simple variable takes up less space than an arrayed variable... Thats why it´s less efficient in THIS TRIGGER.... Not in the others but in this...
     
  20. overcold_ice

    overcold_ice

    Joined:
    Apr 30, 2011
    Messages:
    356
    Resources:
    0
    Resources:
    0
    better not fighting :3
    you don't understand as well . . . .