• 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] Creating a Random Item upon Purchasing Mercenary

Status
Not open for further replies.
Level 6
Joined
May 1, 2009
Messages
215
  • Events
    • A Unit Sells A Unit
  • Conditions
    • Unit Type of Sold Unit Equal to Item Cache
  • Actions
    • Set RandomNumber Equal to Random Integer between 0 and 100
    • If (All Conditions Are True) then do Then Actions else do Else Actions
      • If - Conditions
        • RandomNumber Greater than 96
        • RandomNumber Less than or Equal to 100
    • Then - Actions
      • Create Random Level 8 Miscellaneous item type and give it to buying unit
    • Else - Do Nothing
The above if / then / else repeats several times (going through values 1-96).
The trigger runs (returns some text as I've told it to) but no item is created no matter how many times I buy the sold unit.

Why? I've wasted an hour trying to figure it out, changing the system around (to spawn item in a region, spawn at position of unit, etc.) and it won't work at all. I think it has to do with the RandomNumber integer, perhaps the and condition isn't working but I'd rather ask before I redo this thing again for the third time.
 
Level 10
Joined
Nov 28, 2008
Messages
655
Are you testing it in the "test map" button?

Then you need to set something in preferences, other wise all random numbers are the same number.

File :fp: Preferences :fp: Test Map

Or, just save the map and load it in the actual game.

Hope that helps.
 
Level 6
Joined
May 1, 2009
Messages
215
This only gives a 4% chance to make an item o.o are you sure it actually got the 4% chance?

Well it's a 4% chance for level 8 but I have 7 other triggers which give percentages of drop rates for items 1-7 so it's a 100% chance to get any kind of item. No item is spawning. Sorry if I didn't explain this well enough.

It has to be a AND Condition for both conditions to work properly i think

Well the If/Then/Else says 'all condtions must be true' but I did put 'and' and it made no difference

I am test mapping, but that shouldn't make any difference since there's a 100% chance to get an item and no item is spawning.

Wait... do you want the item to goto the merc or the unit unit standing by the shop that is buying the merc?

At this point it doesn't matter, I just want an item to spawn, the logistics of where it will go are insignificant.
 
Level 6
Joined
May 1, 2009
Messages
215
I've done that. The original trigger functioned like that.

It's not the events - the trigger runs just fine, I said that. It's something else! It's either 'create random item' or there's something wrong with the conditions 'between x and y'. I can't even get the 'create random item of type' to work outside of this trigger - which doesn't make any sense.
 
Level 10
Joined
Nov 28, 2008
Messages
655
1. If the random int is between 0-100, why does the condition have to put it at x <= 100 ? You could take out that second condition.
2. Just a double check, did you make any level 8 misc items? because default there are none.

-- maybe you need to put the items in a group and do a random one from that? if that is possible.
 
Level 6
Joined
May 1, 2009
Messages
215
If the random int is between 0-100, why does the condition have to put it at x <= 100 ? You could take out that second condition.

No, when the random number is generated it's somewhere between 0-100. If the number is 97, a level 8 item should be spawned, if it's 98, 99 or 100, it should also happen. To accomplish this, aside from making 100 triggers, is to use "great than or equal to" and "less than" or visa versa. Think about number lines.

As I said in the initial post the trigger I posted is a shortened version. I also have it so 87-96 creates a level 7 item, 79-87 makes level 6, 70-79 makes level 5, 56-70 makes level 4, 43-56 makes level 3, 43-23 makes level 2, 10-23 makes level 1, 0-10 makes level 0. (realize that although the numbers over lap one is greater than or equal to and one is less than) It has to happen like this. This is all happening in 1 trigger. I need the upper and lower bounds otherwise tons of items will spawn instead of just one.

2. Just a double check, did you make any level 8 misc items? because default there are none.

I moved all the items I want to spawn into the item classification 'miscellaneous' in the editor, there are level 8,7,6,5,4,3,2,1,0 miscellaneous items and with a 100% chance to drop an item of any level by now I should have gotten something, even if that weren't the case.

As for your last suggestion, what do you mean by that? I considered spawning a unit and giving that unit an item table and then killing it - but I can't seem to find a way to do that (only NH creeps have that function and that's only if they're placed in the editor).

Also, if I have to manually put in a chance for each item to drop (or just add them all to an item table) that would take hours... I have tons of items. That's why it's being done this way.
 
Level 11
Joined
May 31, 2008
Messages
698
Well i made this and it works fine

  • Untitled Trigger 001
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Sold unit)) Equal to Footman
    • Actions
      • Unit - Remove (Sold unit) from the game
      • Set RandomInteger = (Random integer number between 1 and 10)
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • RandomInteger Less than or equal to 4
          • Then - Actions
            • Hero - Create (Random level 1 item-type) and give it to (Buying unit)
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • RandomInteger Greater than or equal to 5
            • RandomInteger Less than or equal to 7
          • Then - Actions
            • Hero - Create (Random level (Random integer number between 2 and 3) item-type) and give it to (Buying unit)
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • RandomInteger Greater than or equal to 8
            • RandomInteger Less than or equal to 9
          • Then - Actions
            • Hero - Create (Random level (Random integer number between 4 and 6) item-type) and give it to (Buying unit)
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • RandomInteger Equal to 10
          • Then - Actions
            • Hero - Create (Random level (Random integer number between 7 and 8) item-type) and give it to (Buying unit)
          • Else - Actions
 
Level 6
Joined
May 1, 2009
Messages
215
Hmm interesting... I guess I'll give your trigger a try. The only difference I can see is you did "equal to" everywhere, skipping numbers in-between (which is fine since we're working with integers). Oh and you didn't specify the item type.
 
Level 6
Joined
May 1, 2009
Messages
215
Why did you bump this? I really don't appreciate this, pk.

I resolved the issue. I changed the item type spawn from Misc. to none and made all the items I didn't want to be spawned level 9. I guess trying to spawn items of type doesn't work in GUI or something.
 
Status
Not open for further replies.
Top