• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] "Perfomance" questions

Status
Not open for further replies.
Level 20
Joined
Oct 21, 2006
Messages
3,230
So, lets say that I have 10 triggered spells. Is it better to but them into one trigger and then add mass if/then/else condition or use 10 triggers? Well if I use 10 triggers it would actually launch them all everyone time any spell is casted, but if I use if/then/else it would be faster(?) and minimize map size.

So does it really matter? :s
 
Level 6
Joined
Jul 25, 2005
Messages
221
Each trigger made contains on its own an inital amount of code but that should not affect the performance, but I've seen what the GUI does to the If blocks, and I'd definatly say you should avoid doing a massive amount of If blocks in the same trigger. Not to mention that every time someone casts a spell the trigger has to go through all the If statements, and that takes alot from the performance. Making efficient code will be more and more clear along the way, but for now you should know:
1) Making separate triggers saves trouble, makes it easy on the eyes and increases performance overall
2) If blocks generally decreases the performance of that trigger (not by much tho), but adding alot of If chunks will result in a really slow trigger.

  • StackingIfs
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
    • Actions
      • -------- NO --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Animate Dead
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
            • Then - Actions
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Attribute Bonus
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                • Then - Actions
                • Else - Actions
            • Else - Actions
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
            • Then - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
            • Then - Actions
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Avatar
        • Then - Actions
        • Else - Actions
  • NotStacking Ability0
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • -------- YES --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
        • Else - Actions
  • NotStacking Ability1
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Attribute Bonus
    • Actions
      • -------- YES --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
        • Else - Actions
 
Level 20
Joined
Oct 21, 2006
Messages
3,230
When I'm using If/Then/Else I have ONE event, Unit casts spell.

If I seperated them all to 10 triggers and they all have same event. Every time spell is casted they ALL would run and try to check conditions, so its actually same thing.. Right? But actually it could be just better to make 10 triggers, cause long triggers can get hard to read over time. :/

I wanted to ask these things cause I have seen many systems (like Inventory System) and they use something like only 2 triggers with mass If/Then/Else.
 
Level 6
Joined
Jul 25, 2005
Messages
221
Yes Super-Sheep, it is easier to make 10 triggers and avoiding the big chunks of ifs!
Efficient coding! Huzzah! :D
GUI is in my opinion obsolete and you should focus on JASS, but this is the way to go.
Create 1 trigger for each spell, and then categorize them so you can easily seperate them. Just read my first post in this thread, I just added some YES and NO's

http://www.hiveworkshop.com/forums/1102843-post3.html
 
Level 20
Joined
Oct 21, 2006
Messages
3,230
I was making it like

IF CONDITION IS TRUE
- THEN - RANDOM ACTIONS
- ELSE - IF CONDITION IS TRUE
- - - - - THEN - RANDOM ACTIONS
- - - - - ELSE - IF - CONDITION IS TRUE
- - - - - - - - - THEN - RANDOM ACTIONS
- - - - - - - - - ELSE - IF CONDITION IS TRUE
- - - - - - - - - - - - - ...

Actually I have used this method only in one map. And you dont have to make tuto im not noob. ><
 
Status
Not open for further replies.
Top