| 
        
       | 
      
        
          
              | 
              | 
           
          
              | 
              | 
              | 
           
          
              | 
            
              
                
                  
                    
                      
                        | World Editor FAQ: Triggers | 
                       
                     
                   | 
                 
                
                  
                    
                      
                        
                          
                            
                              
                                Q: 
                               | How do I copy and paste my triggers into a forum post?
                                 
                             |  
                              | 
                                A: | 
                              Select your trigger and go to "Edit->Copy As Text". Then paste your text where you
                                want it. Your text will be much easier to read if you add [pre] to the start and
                                [/pre] to the end. | 
                             
                           
                          
                            
                              
                                Q: 
                               | Where can I find a trigger tutorial?
                                 
                             |  
                              | 
                                A: | 
                              In the World Editor go to "Help->Warcraft III World Editor Help...". Then in your web
                                browser scroll down the menu until you get to the section named "The Trigger Editor".
                                Click on that. | 
                             
                           
                          
                            
                              
                                Q: 
                               | Where are the triggers?
                                 
                             |  
                              | 
                                A: | 
                              Go to "Module->Trigger Editor" | 
                             
                           
                          
                            
                              
                                Q: 
                               | What are triggers for?
                                 
                             |  
                              | 
                                A: | 
                              Triggers make things happen in your map. You can do things like create units, run
                                computer AIs, or give units orders. | 
                             
                           
                          
                            
                              
                                Q: 
                               | What is the event part of a trigger for?
                                 
                             |  
                              | 
                                A: | 
                              Events decide when the trigger will run. If you have many events the trigger will run
                                each time any of the events happen. Some triggers have no events, and are instead called
                                from other triggers. | 
                             
                           
                          
                            
                              
                                Q: 
                               | What is the condition part of a trigger for?
                                 
                             |  
                              | 
                                A: | 
                              Each time your trigger would be run, the conditions are checked first. The trigger
                                only runs if all of the conditions are true. Many triggers do not have conditions, and
                                so they run every time their event happens.  You can use this to narrow the range of
                                events that the trigger runs for. For example you could have an event that fires every
                                time an item is used, then in your conditions you check to see if the item used is a
                                healing potion, and only run the actions if it is.  | 
                             
                           
                          
                            
                              
                                Q: 
                               | What is the action part of a trigger for?
                                 
                             |  
                              | 
                                A: | 
                              Actions are the most important part of a trigger. They make things happen in the game.
                                All triggers should have at least one action. | 
                             
                           
                          
                            
                              
                                Q: 
                               | What is a Variable?
                                 
                             |  
                              | 
                                A: | 
                              A variable is a place to put information. You store a value in a variable, and then
                                when you access it later you get back the value you stored in it.Set x = 1337
                                Game - Display to (All players) the text: (String(x))Would display "1337" to
                                  all players.
                               | 
                             
                           
                          
                            
                              
                                Q: 
                               | What are integers, reals, booleans, and strings? 
                                 
                             |  
                              | 
                                A: | 
                              Integers are numbers without decimals (...-2, -1, 0, 1, 2...)
  
                                Reals are numbers with decimals (-12.0, -3.2, 0.0, 5.2...) Note that the decimal part
                                can be zero.
  
                                A boolean is either true or false.
  
                                A string is a group of characters ("dog", "cat", "dfsf dsfsdf sd46t4")  | 
                             
                           
                          
                            
                              
                                Q: 
                               | What is an array?
                                 
                             |  
                              | 
                                A: | 
                              An array is a way to store more than one value in a single variable. For example
                                without an array you could have separate variables named Unit1 Unit2 and Unit3, or you
                                could have one array, and access it through Unit<1>, Unit<2>, and Unit<3>. The advantage
                                      is that you can use functions, like Unit<1+1> would be Unit<2>. | 
                             
                           
                          
                            
                              
                                Q: 
                               | What does the size of the array mean?
                                 
                             |  
                              | 
                                A: | 
                              If you access a part of an array that you have not stored anything in yet, then
                                Warcraft may crash or people may disconnect. If you set a size for your array, then the
                                first entries in the array will be created and initialized for you. You can still add
                                entries beyond the original size, but make sure you assign them before you access them.
                                
  
                                Warcraft will actually allocate space for one more entry than you ask for. For example
                                if set an array's size to 3, then entries 0, 1, 2, 3 will all be created. This is so you
                                can start using the array at either 0 or 1 and still have 3 entries.
                               | 
                             
                           
                          
                            
                              
                                Q: 
                               | How do I make a two-dimensional array, or an array of arrays?
                                 
                             |  
                              | 
                                A: | 
                              A two-dimensional array is just a different way of accessing a standard array. Instead
                                of accessing index myArray[x] access myArray[x + y * Xmax]. There is no simple way to
                                make an array of arrays. | 
                             
                           
                          
                            
                              
                                Q: 
                               | How do I get normal units to give gold on death like creeps?
                                 
                             |  
                              | 
                                A: | 
                              Create a trigger action "player - turn player flag (gives bounty) (on) for (player)".
                                You can edit how much a unit-type drops under the "Bounty Awarded" section in the unit
                                editor. | 
                             
                           
                          
                            
                              
                                Q: 
                               | If I use the event "Map Initialization", then when will my actions happen?
                                 
                             |  
                              | 
                                A: | 
                              They will happen during the loading screen, before your map is visible. Don't create
                                leaderboards, timer windows, or dialogs on map initialization because they need the map
                                to be visible. | 
                             
                           
                          
                            
                              
                                Q: 
                               | How do I use cameras? 
                                 
                             |  
                              | 
                                A: | 
                              A camera is the point of view from which a player sees the map. If you "apply" a
                                camera using a trigger action, then it will set the viewpoint to that camera. Note that
                                unless you are in cinematic mode or lock the camera, players can still move their
                                viewpoint around by scrolling or using the mouse wheel.
  If you use multiple
                                cameras you will want to use wait actions between them. Otherwise they will all be
                                applied at the same instant, and you end up only using the last one.  | 
                             
                           
                          
                            
                              
                                Q: 
                               | How do I lock the camera on a unit?
                                 
                             |  
                              | 
                                A: | 
                              Create a trigger action "Camera - lock camera target for (player) to (unit) ..." | 
                             
                           
                          
                            
                              
                                Q: 
                               | How do I give a unit timed life, like a summoned unit?
                                 
                             |  
                              | 
                                A: | 
                              Unit - Add expiration timer. | 
                             
                           
                          
                            
                              
                                Q: 
                               | How do I display a number as text or use an integer where I need a real number?
                                 
                             |  
                              | 
                                A: | 
                              Use the conversion functions, like "Conversion - Convert Real to String", or
                                "Conversion - Convert Integer to Real". | 
                             
                           
                          
                            
                              
                                Q: 
                               | How can I play imported music in my map?
                                 
                             |  
                              | 
                                A: | 
                              
                                Go to "Module->Sound Editor->File->Import Sound..." and import your file.
                                Still under Sound Editor right click on the imported file and select "Use As Music".
                                In the trigger editor, create a trigger action "Sound - Play Music".
                                For "music" choose "variable" then pick the music file you imported.
                               | 
                             
                           
                          
                            
                              
                                Q: 
                               | How do I give orders to units owned by a computer? 
                                 
                             |  
                              | 
                                A: | 
                              Make sure you use "AI - Ignore Unit Guard Position" action first. Otherwise the AI
                                will try to move the unit around. This doesn't work for neutral units though, the AI
                                will always try to move them. | 
                             
                           
                          
                            
                              
                                Q: 
                               | Why is my map lagging?
                                 
                             |  
                              | 
                                A: | 
                              
                                You have too many units.
                                You are telling a large number of units to move at the same time.
                                You are creating a large number of units at one time.
                                You have too many doodads, special effects, or units on the screen at once.
                                You constantly create persistent special effects but never destroy them.
                                You have periodic events firing too often. If your periodic event needs to fire more
                                  than once a second then you should probably use a different kind of event.
                                You have many timers or wait statements running at once.
                               | 
                             
                           
                          
                            
                              
                                Q: 
                               | How do I use a variable in an event?
                                 
                             |  
                              | 
                                A: | 
                              With the exception of the "Value of Real Variable" event, you can't use variables in
                                the GUI events. This is because these events are registered one time, using the current
                                value of the variable. They are registered at the very start of the map, so your
                                variable doesn't have a value yet.
                                
  
                                You can however, register new events in the middle of a game using the trigger action
                                "Trigger - Add New Event". In that case the current value of the variable can be used.
                                Remember though that changing the variable afterward will not change the event in
                                any way.
                               | 
                             
                           
                          
                            
                              
                                Q: 
                               | How do I keep track of multiple visibility modifiers/units/doodads/special effects,
                                  if I create them all at once? 
                                 
                             |  
                              | 
                                A: | 
                              "Last Created X" will only keep track of one "X" at a time. If you want to remember
                                all of them, you will need to split the creation up so that you create one, then store
                                the last created one in an array. You can use a loop with multiple actions to create
                                your objects one at a time, and store each in the array before creating the
                                next.
  Note that if you use the "Create N Units..." action then "Last created Unit
                                Group" will refer to all of the units created through that action.  | 
                             
                           
                          
                            
                              
                                Q: 
                               | How can I pass an argument from one trigger to another?
                                 
                             |  
                              | 
                                A: | 
                              You can't. Instead set the value of a global variable in the first trigger and read in
                                the second. As long as you use no wait statements between setting and retrieving you can
                                be assured no other triggers will run during that time.  | 
                             
                           
                          
                            
                              
                                Q: 
                               | How do I make a creep drop an item if I created the creep through a trigger? 
                                 
                             |  
                              | 
                                A: | 
                              You need to make them drop items through triggers as well. The "Item Drop Demo" on
                                this page has two examples http://www.elilz.com/demomaps.html  | 
                             
                           
                          
                            
                              
                                Q: 
                               | How do I change a Hero's name using triggers?
                                 
                             |  
                              | 
                                A: | 
                              You can't. You could replace the hero with a different type of unit that is identical
                                except for the name. | 
                             
                           
                          
                            
                              
                                Q: 
                               | How do I scale a special effect?
                                 
                             |  
                              | 
                                A: | 
                              You can't. Instead, make a destructible with the model you want that acts like a
                                special effect. Turn off "Art - Selectable In Game" and adjust the "Combat - Targeted
                                As" field so nothing can target it.  | 
                             
                           
                          
                            
                              
                                Q: 
                               | How do I enter a really long string?
                                 
                             |  
                              | 
                                A: | 
                              Use the "Conversion - Convert Externalized String" function before entering your
                                string. This will cause the actual string to get "externalized" into the map string file
                                (.wts). | 
                             
                           
                          
                            
                              
                                Q: 
                               | How do I use arrays of groups, timers, forces, triggers, or dialogs? "group" is a
                                  unit group and "force" is a player group.
                                 
                             |  
                              | 
                                A: | 
                              A group variable is not a group, it is a pointer to a group. You could have two
                                pointers pointing to the same group, or you could have a pointer that points to no group
                                at all. At the start of your map all group variables will be pointing to nothing. Before
                                you can add units to a group, you will need to first create the group, then add units to
                                it.
  The same applies to the timers, forces, triggers, and dialogs. Warcraft will
                                do this automatically if you set the array size in the variable editor. | 
                             
                           
                          
                            
                              
                                Q: 
                               | I tried to do "for each x do (skip remaining actions)", but it didn't work.
                                  Why?
                                 
                             |  
                              | 
                                A: | 
                              "Skip Remaining Actions" translates into the statement "return". It isn't a function
                                the same way that most trigger actions are. If you try this within a single action loop
                                then your trigger will have an error. If you try this in a multiple action loop then it
                                will only skip the actions remaining in that instance of the loop. Note that this
                                doesn't apply to "For Each Integer A...". | 
                             
                           
                          
                            
                              
                                Q: 
                               | How big can an array be?
                                 
                             |  
                              | 
                                A: | 
                              The maximum array size is 8192. If you try to access a value beyond that, it will
                                always come out as zero or "null".
                               | 
                             
                           
                          
                            
                              
                                Q: 
                               | How do I destroy special effects automatically?
                                 
                             |  
                              | 
                                A: | 
                              Make a trigger like this:  
                                
    Custom script:   local effect udg_LocalEffect
    Set LocalEffect = (Last created special effect)
    Wait 5.00 seconds
    Special Effect - Destroy LocalEffect
                                Then call that trigger once immediately after you create each effect.
                               | 
                             
                           
                          
                            
                              
                                Q: 
                               | For the trigger action "Special Effects - Attach Special Effect to Unit", what are
                                  the attachment points? 
                                 
                             |  
                              | 
                                A: | 
                              The following information might be of use to those of you attempting to use the
                                "Special Effect - Create Special Effect On Unit" trigger action. The first parameter for
                                this action is an attachment point name, which is a string value that you type in
                                manually.
  
                                One or more modifiers can be added to an attachment point name to specify the exact
                                location to which you want to attach the special
                                effect. These modifiers are optional, and are not defined for all units and attachment
                                point names. Example attachment point names:
                                "overhead", "hand", "hand left", "foot right mount rear".
  
                                Attachment Point Names:
                                overhead (floats over the unit's head, but doesn't sway with the head as it
                                  animates)
                                head (sways with the unit's animation)
                                  chest
                                origin (usually at the base of a unit's feet)
                                hand
                                foot
                                weapon (for heroes)
                                sprite (for buildings)
                                medium (for buildings)
                                large (for buildings)
                                  
  
                                  Attachment Point Modifiers:
                                left
                                right
                                mount (for mounted units)
                                rear (for quadrupeds)
                                first (for buildings)
                                second (for buildings)
                                third (for buildings)
                                fourth (for buildings)
                                fifth (for buildings)
                                sixth (for buildings)
                                rallypoint (for buildings)
                                  (We don't know who wrote this, if you wrote it let me know so I can include your
                                  handle in the credits)
                               | 
                             
                           
                          
                            
                              
                                Q: 
                               | How do I use a custom hero skill with the "Learned Hero Skill" condition or the
                                  "Hero - Learn skill" action?
                                
                                 
                             |  
                              | 
                                A: | 
                              First, make your trigger, using the "Avatar" ability in place of your custom ability.
                                Then go to "Edit->Convert To Custom Text" and convert your trigger to custom text (you
                                might want to save a copy of your trigger first, in case you want to go back). The code
                                for Avatar is 'AHav', find that part in your trigger and replace it with your custom
                                spell's 4-letter code (you can find it in the Object Editor by turning on
                                "View->Displays Values As Raw Data" or pressing Ctrl+D).
                                
  
                                If you want you can use the "Custom Script" action instead of using the converted
                                trigger. In that case copy the line of text you just changed, and put it inside a
                                "Custom Script" action in the appropriate place in your trigger.
                               | 
                             
                           
                          
                         | 
                       
                     
                   | 
                 
               
             | 
           
          
              | 
              | 
              | 
           
          
              | 
              | 
           
         
       |