• 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 Causes Crash

Status
Not open for further replies.
Level 7
Joined
Nov 18, 2012
Messages
272
[Solved] Trigger Causes Crash

  • Backpacks and Pouches
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to Backpack
          • (Item-type of (Item being manipulated)) Equal to Pouch
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Pouch
          • (Level of Inventory (Simple) for (Hero manipulating item)) Equal to 1
        • Then - Actions
          • For each (Integer Inventory) from 1 to 2, do (Actions)
            • Loop - Actions
              • Set Item[Inventory] = (Item carried by (Hero manipulating item) in slot Inventory)
              • Hero - Drop Item[Inventory] from (Hero manipulating item)
          • Unit - Remove Inventory (Simple) from (Hero manipulating item)
          • Unit - Add Inventory (BackPack 1) to (Hero manipulating item)
          • For each (Integer Inventory) from 1 to 2, do (Actions)
            • Loop - Actions
              • Hero - Give Item[Inventory] to (Hero manipulating item)
              • Set Item[Inventory] = No item
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to Backpack
              • (Level of Inventory (Simple) for (Hero manipulating item)) Equal to 1
            • Then - Actions
              • For each (Integer Inventory) from 1 to 4, do (Actions)
                • Loop - Actions
                  • Set Item[Inventory] = (Item carried by (Hero manipulating item) in slot Inventory)
                  • Hero - Drop Item[Inventory] from (Hero manipulating item)
              • Unit - Remove Inventory (Simple) from (Hero manipulating item)
              • Unit - Add Inventory (BackPack 2) to (Hero manipulating item)
              • For each (Integer Inventory) from 1 to 4, do (Actions)
                • Loop - Actions
                  • Hero - Give Item[Inventory] to (Hero manipulating item)
                  • Set Item[Inventory] = No item
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item-type of (Item being manipulated)) Equal to Backpack
                  • (Level of Inventory (BackPack 1) for (Hero manipulating item)) Equal to 1
                • Then - Actions
                  • For each (Integer Inventory) from 1 to 4, do (Actions)
                    • Loop - Actions
                      • Set Item[Inventory] = (Item carried by (Hero manipulating item) in slot Inventory)
                      • Hero - Drop Item[Inventory] from (Hero manipulating item)
                  • Unit - Remove Inventory (BackPack 1) from (Hero manipulating item)
                  • Unit - Add Inventory (BackPack 2) to (Hero manipulating item)
                  • For each (Integer Inventory) from 1 to 4, do (Actions)
                    • Loop - Actions
                      • Hero - Give Item[Inventory] to (Hero manipulating item)
                      • Set Item[Inventory] = No item
                • Else - Actions
                  • Do nothing
Trigger is pretty self explanatory (I hope)

What's wrong with it?
 
Last edited:
Level 7
Joined
Nov 18, 2012
Messages
272
Will this do?
  • Backpacks and Pouches
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to Backpack
          • (Item-type of (Item being manipulated)) Equal to Pouch
    • Actions
      • Trigger - Turn off (This trigger)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Pouch
          • (Level of Inventory (Simple) for (Hero manipulating item)) Equal to 1
        • Then - Actions
          • For each (Integer Inventory) from 1 to 2, do (Actions)
            • Loop - Actions
              • Set Item[Inventory] = (Item carried by (Hero manipulating item) in slot Inventory)
              • Hero - Drop Item[Inventory] from (Hero manipulating item)
          • Unit - Remove Inventory (Simple) from (Hero manipulating item)
          • Unit - Add Inventory (BackPack 1) to (Hero manipulating item)
          • For each (Integer Inventory) from 1 to 2, do (Actions)
            • Loop - Actions
              • Hero - Give Item[Inventory] to (Hero manipulating item)
              • Set Item[Inventory] = No item
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to Backpack
              • (Level of Inventory (Simple) for (Hero manipulating item)) Equal to 1
            • Then - Actions
              • For each (Integer Inventory) from 1 to 4, do (Actions)
                • Loop - Actions
                  • Set Item[Inventory] = (Item carried by (Hero manipulating item) in slot Inventory)
                  • Hero - Drop Item[Inventory] from (Hero manipulating item)
              • Unit - Remove Inventory (Simple) from (Hero manipulating item)
              • Unit - Add Inventory (BackPack 2) to (Hero manipulating item)
              • For each (Integer Inventory) from 1 to 4, do (Actions)
                • Loop - Actions
                  • Hero - Give Item[Inventory] to (Hero manipulating item)
                  • Set Item[Inventory] = No item
            • Else - Actions
              • Do nothing
      • Trigger - Turn on (This trigger)
 
Level 5
Joined
Nov 30, 2012
Messages
200
It's probably because you're using the Event - A Unit Acquires an Item, which will fire every time a unit gets an item (of course), but the problem arises when the unit is given an item that will fire the trigger again, leading to an endless loop. Try implementing Faestus' changes, i.e. turning off the trigger then turning it on again.
 
Yes, the endless loop thing is your culprit.

Best solution: Define a global boolean that is set to TRUE before giving an item to a unit by trigger and back to FALSE right after that.
Then simply check for the boolean to be FALSE in the triggercondition.

Better solution than turning the trigger on and off all the time.
 
Status
Not open for further replies.
Top