• 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] something is wrong with that library...

Status
Not open for further replies.
Level 9
Joined
Aug 21, 2008
Messages
533
Need help with this drop trigger

First off all i made a library:
  • item library
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- -----------------------------------------weapons------------------------------------- --------
      • Set index2 = 1
      • Set index[index2] = 1
      • Set itemdrop[index[index2]] = stone axe
      • Set index[index2] = (index[index2] + 1)
      • Set itemdrop[index[index2]] = good stone axe
      • Set index[index2] = (index[index2] + 1)
      • Set itemdrop[index[index2]] = perfect stone axe
      • Set index[index2] = (index[index2] + 1)
      • Set itemdrop[index[index2]] = iron axe
      • Set index[index2] = (index[index2] + 1)
      • Set itemdrop[index[index2]] = good iron axe
      • Set index[index2] = (index[index2] + 1)
      • Set itemdrop[index[index2]] = perfect iron axe
      • Set index[index2] = (index[index2] + 1)
      • Set itemdrop[index[index2]] = steel axe
      • Set index[index2] = (index[index2] + 1)
      • Set itemdrop[index[index2]] = good steel axe
      • Set index[index2] = (index[index2] + 1)
      • Set itemdrop[index[index2]] = perfect steel axe
      • -------- -----------------------------------------armor------------------------------------- --------
      • Set index2 = 2
      • Set index[index2] = 1
      • Set itemdrop[index[index2]] = old cloth armor
      • Set index[index2] = (index[index2] + 1)
      • Set itemdrop[index[index2]] = cloth armor
      • Set index[index2] = (index[index2] + 1)
      • Set itemdrop[index[index2]] = new cloth armor
      • Set index[index2] = (index[index2] + 1)
      • Set itemdrop[index[index2]] = old leather armor
      • Set index[index2] = (index[index2] + 1)
      • Set itemdrop[index[index2]] = leather armor
      • Set index[index2] = (index[index2] + 1)
      • Set itemdrop[index[index2]] = new leather armor
      • Set index[index2] = (index[index2] + 1)
      • Set itemdrop[index[index2]] = old hardened leather armor
      • Set index[index2] = (index[index2] + 1)
      • Set itemdrop[index[index2]] = hardened leather armor
      • Set index[index2] = (index[index2] + 1)
      • Set itemdrop[index[index2]] = new hardened leather armor
Now i made a drop trigger:

  • Drops
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 12 (Brown)
    • Actions
      • Set index2 = (Random integer number between 1 and 4)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • index2 Equal to 1
        • Then - Actions
          • Set index2 = (Random integer number between 1 and 2)
          • Set index[index2] = (Random integer number between 0 and 3)
          • Set index[index2] = (index[index2] + (Level of (Triggering unit)))
          • Item - Create itemdrop[index[index2]] at (Position of (Triggering unit))
        • Else - Actions
But now only the armors are dropping...
Cans omeone help?
 
Last edited:
Level 18
Joined
Aug 23, 2008
Messages
2,319
That's because there's a pre-programmed random number generator in the test function of the World Editor. You do a random number and every time you'll test the game with the World Editor, it'll be the same number. That's because there's an option for that which is set like that by default.

Open the World Editor, go to File --> Preferences..., go to the Test Map tab and switch the box named 'Use Fixed Random Seed'.
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
No, the library is alright. Your method is clear to read, but takes more space. If you want to dubble-check your library, you can also just say 'Set itemdrop[1] = stone axe' and remove all [index[index2]] parts in the library.

Nevertheless, if there was a problem with your library, why would the armor work and the weapons wouldn't? They're made the exact same, index2 is just made 2 instead of 1, which is why I come back to my previous statement: "The cause would be the 'Set index2 = (Random integer number between 1 and 2)' always being 2, but why, I wouldn't know."
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
If you said:
  • Drops
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 12 (Brown)
    • Actions
      • Set index2 = (Random integer number between 1 and 4)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • index2 Equal to 1
        • Then - Actions
          • Set index2 = 1
          • Set index[index2] = (Random integer number between 0 and 3)
          • Set index[index2] = (index[index2] + (Level of (Triggering unit)))
          • Item - Create itemdrop[index[index2]] at (Position of (Triggering unit))

Then it should always pick a weapon, because it would make it:

  • Set index2 = 1
  • Set index[1] = (Random integer number between 0 and 3)
  • Set index[1] = (0-3 + (Level of (Triggering unit)))
  • Item - Create itemdrop[0-level+3] at (Position of (Triggering unit))
  • Else - Actions
Let's say a lvl 1 unit with a random pick of 0 dies. That would drop itemdrop[1]


Now if we pull that back to the library, we look up which is itemdrop[1].
  • Set index2 = 1
  • Set index[index2] = 1
  • Set itemdrop[index[index2]] = stone axe
and
  • Set index2 = 2
  • Set index[index2] = 1
  • Set itemdrop[index[index2]] = old cloth armor
Which makes it
  • Set index2 = 1
  • Set index[1] = 1
  • Set itemdrop[1] = stone axe
and
  • Set index2 = 2
  • Set index[2] = 1
  • Set itemdrop[1] = old cloth armor
And tah-dah: You've got your problem :D
You first set all itemdrop[x]'s to weapons and then re-wrote them all over to armor, so you'd always get armor. To solve this, just re-write the arrays. Let's say 1xx is for weapons and 2xx is for armor, giving you itemdrop[101] for stone axe and itemdrop[201] for old cloth armor. You can check the arrays with substrings then :wink:


I really had to go through this step by step to find that bug xD
Try using more straight-forward triggering.
  • Set itemdrop[1] = old cloth armor
  • ----------instead of----------
  • Set index2 = 2
  • Set index[2] = 1
  • Set itemdrop[1] = old cloth armor
This will prevent such mistakes.
 
Level 9
Joined
Aug 21, 2008
Messages
533
hmmm k ty for that hint^^ you prevent me from making something like this with all item types:
  • new item library
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Weapon[1] = stone axe
      • Set Weapon[2] = good stone axe
      • Set Weapon[3] = perfect stone axe
      • Set Weapon[4] = iron axe
      • Set Weapon[5] = good iron axe
      • Set Weapon[6] = perfect iron axe
      • Set Weapon[7] = steel axe
      • Set Weapon[8] = good steel axe
      • Set Weapon[9] = perfect steel axe
      • Set armor[1] = old cloth armor
      • Set armor[2] = cloth armor
      • Set armor[3] = new cloth armor
      • Set armor[4] = old leather armor
      • Set armor[5] = leather armor
      • Set armor[6] = new leather armor
      • Set armor[7] = old hardened leather armor
      • Set armor[8] = hardened leather armor
      • Set armor[9] = new hardened leather armor
      • Set shield[1] = old wooden shield
      • Set shield[2] = wooden shield
      • Set shield[3] = new wooden shield
      • Set shield[4] = old big wooden shield
      • Set shield[5] = big wooden shield
      • Set shield[6] = new big wooden shield
      • Set shield[7] = old iron shield
      • Set shield[8] = iron shield
      • Set shield[9] = new iron shield
and
  • Drops Copy
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 12 (Brown)
    • Actions
      • Set index2 = (Random integer number between 1 and 4)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • index2 Equal to 1
        • Then - Actions
          • Set index2 = (Random integer number between 1 and 3)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • index2 Equal to 1
            • Then - Actions
              • Set index2 = (Random integer number between 0 and 2)
              • Set index2 = (index2 + (Level of (Triggering unit)))
              • Item - Create Weapon[index2] at (Position of (Triggering unit))
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • index2 Equal to 2
            • Then - Actions
              • Set index2 = (Random integer number between 0 and 2)
              • Set index2 = (index2 + (Level of (Triggering unit)))
              • Item - Create armor[index2] at (Position of (Triggering unit))
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • index2 Equal to 3
            • Then - Actions
              • Set index2 = (Random integer number between 0 and 2)
              • Set index2 = (index2 + (Level of (Triggering unit)))
              • Item - Create shield[index2] at (Position of (Triggering unit))
            • Else - Actions
        • Else - Actions
which causes many dual drops which i doesnt like :(

Edit: Tested it works fine now
 
Last edited:
Status
Not open for further replies.
Top