• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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

Status
Not open for further replies.
Level 4
Joined
Mar 28, 2009
Messages
66
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:
Level 17
Joined
Feb 11, 2011
Messages
1,860
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.
 
Level 16
Joined
Jun 24, 2009
Messages
1,409
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
 
Level 16
Joined
Jun 24, 2009
Messages
1,409
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
            • ......
 
Level 7
Joined
Apr 30, 2011
Messages
359
  • 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
            • ......

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"
 
Level 16
Joined
Jun 24, 2009
Messages
1,409
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"

What´s the reason of arrayed booleans? There are only 4 players.
 
Level 16
Joined
Jun 24, 2009
Messages
1,409
arrays are better -_-
you can set it in a loop, with variables, etc . . .
more flexible . .

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.
 
Level 7
Joined
Apr 30, 2011
Messages
359
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 . . . .
 
Level 16
Joined
Jun 24, 2009
Messages
1,409
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 . . . .

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...
 
Level 16
Joined
Jun 24, 2009
Messages
1,409
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 . . . .

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...
 
Level 7
Joined
Apr 30, 2011
Messages
359
then we should just stop arguing . . .
there's no more needs of them . . .
it's just our thinking that differs . . . .

please don't reply this post :3
 
Status
Not open for further replies.
Top