• 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] Efficiency question

Status
Not open for further replies.
Level 16
Joined
Jun 24, 2009
Messages
1,409
For a big ORPG map which one spell triggering is better? Which one will create less lagg?

Merge as many triggers as possible.
  • Spells
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Animate Dead
        • Then - Actions
          • Set - Caster - Triggering Unit
          • Set TempLoc - etc....
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Banish
            • Then - Actions
              • Set - Caster - Triggering Unit
              • Set TempLoc - etc....
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Ability being cast) Equal to Blink
                • Then - Actions
                • Else - Actions
Only calling the triggers if it's required.
  • Spells
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set Caster = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Animate Dead
        • Then - Actions
          • Trigger - Run Animate Dead <gen> (checking conditions)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Banish
            • Then - Actions
              • Trigger - Run Banish <gen> (checking conditions)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Ability being cast) Equal to Blink
                • Then - Actions
                  • Trigger - Run Blink <gen> (checking conditions)
                • Else - Actions
Or the simple one:
  • Animate Dead
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • Set Caster = (Triggering unit)
  • Banish
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Banish
    • Actions
      • Set Caster = (Triggering unit)
And for calling dummies which is better? Creating the dummies for the spell then removing it or creating dummies at the init and moving them(with changing ownership) to the required position then if not used sending them back?
 
1) Since you are using TempUnit variable in every statement, don't nest it, set it in the beginning of your actions.

2) I see you did it in the second trigger. Well, will affect efficiency, if you are afraid of that, people are used in creating individual triggers for each spell, but you can alternatively use the second one to run them. Be careful, if the if/then/else list becomes long, it will a) cause your trigger editor to lag a bit, upon the selection of the trigger and b) can affect the in-game construction, because you force the system to loop through every ability, until it finds the proper one.

I'd go for option 2) for an amount of max. 10 abilities; I'd go for option 1) for a higher amount of custom abilities.
 
Once again, you added the second question on editing, it wasn't there :p

MUI spells use multiple units for the effect's creation. There could be some unit recycling, but that would require to check if other instances of all spells are currently running and that's another redundant and laggy procedure, if not done right.
Plus, if a dummy that mimics a missile is used by an instance of one spell and another spell uses the same dummy to issue this missile movement, the game will crash. A unit that is simultaneously moved to two points will crash it.
 
For your first question, I'd stick with multiple triggers. Otherwise, the spells all the way at the bottom of the list will end up being the slowest, which isn't that great. It will also become very messy and hard to deal with. It should be more efficient with separate triggers as well, especially when the list starts to pile up. (although, it uses up more handles, but there are better ways to resolve that)

For the dummies, the recycling method is usually better. However, it is not very necessary or anything. Most of the time, you'll be fine with just a simple Unit - Create <Unit>... and Unit - Remove <Unit>... . The problem with dummies is that you have to get the unit to have instant facing, and other weird things like that. For simplicity, the normal create/remove becomes a bit more practical. :)

Basically, it is what Pharaoh_ said, but I decided to give my remarks anyway. xP
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
I was thinking of a system where you'd store the triggers containing the actions into a hashtable keyed with each ability's raw code.

  • Untitled Trigger 068
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set hash = (Last created hashtable)
      • Custom script: call SaveTriggerHandle(udg_hash, StringHash("triggers"), 'AHhb', gg_trg_Untitled_Trigger_071)
      • Custom script: call SaveTriggerHandle(udg_hash, StringHash("triggers"), 'AHtc', gg_trg_Untitled_Trigger_070)
  • Untitled Trigger 069
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Custom script: call TriggerExecute(LoadTriggerHandle(udg_hash, StringHash("triggers"), GetSpellAbilityId()))
  • Untitled Trigger 070
    • Events
    • Conditions
    • Actions
      • Game - Display to Player Group - Player 1 (Red) the text: Thunder Clap
  • Untitled Trigger 071
    • Events
    • Conditions
    • Actions
      • Game - Display to Player Group - Player 1 (Red) the text: Holy Light
Only one event used handling all abilities, the ability then determines which trigger is called.
 
I was thinking of a system where you'd store the triggers containing the actions into a hashtable keyed with each ability's raw code.

  • Untitled Trigger 068
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set hash = (Last created hashtable)
      • Custom script: call SaveTriggerHandle(udg_hash, StringHash("triggers"), 'AHhb', gg_trg_Untitled_Trigger_071)
      • Custom script: call SaveTriggerHandle(udg_hash, StringHash("triggers"), 'AHtc', gg_trg_Untitled_Trigger_070)
  • Untitled Trigger 069
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Custom script: call TriggerExecute(LoadTriggerHandle(udg_hash, StringHash("triggers"), GetSpellAbilityId()))
  • Untitled Trigger 070
    • Events
    • Conditions
    • Actions
      • Game - Display to Player Group - Player 1 (Red) the text: Thunder Clap
  • Untitled Trigger 071
    • Events
    • Conditions
    • Actions
      • Game - Display to Player Group - Player 1 (Red) the text: Holy Light
Only one event used handling all abilities, the ability then determines which trigger is called.

Jesus4Lyf uses something this in GTrigger and I used it in SpellEffectEvent :)

If there was some way to do this (I don't think GUI can typecast ability id to real), this would be the best method:

  • System
    • Events
      • Unit - A unit starts the effect of an ability
    • Conditions
    • Actions
      • Set Ability = 0.00
      • Custom script: set udg_Ability = GetSpellAbilityId()
  • Spell
    • Events
      • Game - Ability becomes Equal to (Real((My ability)))
    • Conditions
    • Actions
      • -------- Profit!!!11 --------
 
Level 16
Joined
Jun 24, 2009
Messages
1,409
I was thinking of a system where you'd store the triggers containing the actions into a hashtable keyed with each ability's raw code.

  • Untitled Trigger 068
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set hash = (Last created hashtable)
      • Custom script: call SaveTriggerHandle(udg_hash, StringHash("triggers"), 'AHhb', gg_trg_Untitled_Trigger_071)
      • Custom script: call SaveTriggerHandle(udg_hash, StringHash("triggers"), 'AHtc', gg_trg_Untitled_Trigger_070)
  • Untitled Trigger 069
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Custom script: call TriggerExecute(LoadTriggerHandle(udg_hash, StringHash("triggers"), GetSpellAbilityId()))
  • Untitled Trigger 070
    • Events
    • Conditions
    • Actions
      • Game - Display to Player Group - Player 1 (Red) the text: Thunder Clap
  • Untitled Trigger 071
    • Events
    • Conditions
    • Actions
      • Game - Display to Player Group - Player 1 (Red) the text: Holy Light
Only one event used handling all abilities, the ability then determines which trigger is called.

Can the called trigger trigger the ability's values just as target or position of triggering unit? Or I have to set them before one of the triggers are called?
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Everything works normally in the called trigger. For example, this works just fine:

  • Untitled Trigger 072
    • Events
    • Conditions
    • Actions
      • Unit - Create 1 Footman for Player 1 (Red) at (Target point of ability being cast) facing Default building facing degrees
      • Game - Display to Player Group - Player 1 (Red) the text: Flame Strike
      • Wait 2.00 seconds
      • Unit - Kill (Triggering unit)
@Bribe, interesting :)
 
Status
Not open for further replies.
Top