• 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 spell not working 100% of the time?

Status
Not open for further replies.
Level 10
Joined
Apr 3, 2006
Messages
535
Sorry i dont know how to paste triggers so they appaer like they do in WE but here is is the trigger, basicly its a summoning spell and you summon a random creature. Most of the time it works, but sometimes it doeasnt summon anything at all which i cannot understand why.

  • Book of the dead level 1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Book of the Dead (Triggers level 1)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 5) Equal to 1
        • Then - Actions
          • Set Bookdeadpoint = (Position of (Casting unit))
          • Unit - Create 1 Militia for (Owner of (Casting unit)) at Bookdeadpoint facing TempPoint
          • Custom script: call RemoveLocation( udg_Bookdeadpoint )
          • Unit - Add a 60.00 second Generic expiration timer to (Last created unit)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 5) Equal to 2
            • Then - Actions
              • Set Bookdeadpoint = (Position of (Casting unit))
              • Unit - Create 1 Satyr Shadowdancer for (Owner of (Casting unit)) at Bookdeadpoint facing TempPoint
              • Custom script: call RemoveLocation( udg_TempPoint )
              • Unit - Add a 60.00 second Generic expiration timer to (Last created unit)
            • Else - Actions
              • Do nothing
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Random integer number between 1 and 5) Equal to 3
                • Then - Actions
                  • Set Bookdeadpoint = (Position of (Casting unit))
                  • Unit - Create 1 Giant Spider for (Owner of (Casting unit)) at Bookdeadpoint facing TempPoint
                  • Custom script: call RemoveLocation( udg_TempPoint )
                  • Unit - Add a 60.00 second Generic expiration timer to (Last created unit)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Random integer number between 1 and 5) Equal to 4
                    • Then - Actions
                      • Set Bookdeadpoint = (Position of (Casting unit))
                      • Unit - Create 1 Wolf - level 8 for (Owner of (Casting unit)) at Bookdeadpoint facing TempPoint
                      • Custom script: call RemoveLocation( udg_TempPoint )
                      • Unit - Add a 60.00 second Generic expiration timer to (Last created unit)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Random integer number between 1 and 5) Equal to 5
                        • Then - Actions
                          • Set Bookdeadpoint = (Position of (Casting unit))
                          • Unit - Create 1 |cffffcc00Murloc Task Master|r for (Owner of (Casting unit)) at Bookdeadpoint facing TempPoint
                          • Custom script: call RemoveLocation( udg_TempPoint )
                          • Unit - Add a 60.00 second Generic expiration timer to (Last created unit)
                        • Else - Actions
                          • Do nothing
 
Last edited by a moderator:
Level 3
Joined
Dec 23, 2008
Messages
23
Its quite simple.

If - Conditions
(Random integer number between 1 and 5) Equal to 1

If - Conditions
(Random integer number between 1 and 5) Equal to 2

Etc.

See the problem? Each time you cast the spell, it rolls a random integer between 1 and 5, but it doesn't *save* the integer. So basically you have 5 different rolls taking place, not 1. So if the first roll isn't 1, and the second roll isn't 2 etc.. it will work its way through your trigger without activating. Do it like this instead:

1. Create a Variable of the Integer type. Call it, for example, BookDeadRandom.

2. At the very beginning of the trigger, have an action of the Set Variable type that does - Set BookDeadRandom = Random integer number between 1 and 5.

3. Change the conditions of the 5 different possible outcomes to:

If - Conditions
BookDeadRandom Equal to 1

Etc.

That should work, because then you only random once in the trigger, instead of 5 times.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Ciebron.... Although removing leaks is good, in this case it is definatly not the cause.

Do what Clay_More says, its the problem. You are generating a new random integer each condition which means there is a chance for none of them to be met.

Also never use Do Nothing, as it does nothing and is pointless. Avoid it as much as possiable and never use it as an individual action by itself as it is basically an empty function call.
 
Level 10
Joined
Apr 3, 2006
Messages
535
Thank you all for the help! the spell is working perfectlty now, i have also cleared up all the leaks thanks for spotting that aswell. +rep :) to all
 
Status
Not open for further replies.
Top