• 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.

Random Item Spawn Problem

Status
Not open for further replies.
Level 5
Joined
Dec 11, 2010
Messages
101
I have a problem with my system im trying to use. I've tried looking at other threads, but the same problem persists. When I try to create a random item, it will not do it in a random fashion. Instead, it creates the items in a specific order. (Double-Barrel Shotgun, Double-Barrel Shotgun, .357 Magnum, Wunderwaffe, BAR, Wunderwaffe)

Here's my triggers,

  • Set VariableItem
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Item[1] = .357 Magnum
      • Set Item[1] = BAR
      • Set Item[3] = Double-Barrel Shotgun
      • Set Item[4] = Wunderwaffe
  • Untitled Trigger 001
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item carried by (Triggering unit) of type Mystery Weapon)) Equal to Mystery Weapon
    • Actions
      • Set ItemRandomiser = (Random integer number between 1 and 4)
      • Item - Remove (Item carried by (Triggering unit) of type Mystery Weapon)
      • If (ItemRandomiser Equal to 1) then do (Item - Create .357 Magnum at (Center of Region 009 <gen>)) else do (Do nothing)
      • If (ItemRandomiser Equal to 2) then do (Item - Create BAR at (Center of Region 009 <gen>)) else do (Do nothing)
      • If (ItemRandomiser Equal to 3) then do (Item - Create Double-Barrel Shotgun at (Center of Region 009 <gen>)) else do (Do nothing)
      • If (ItemRandomiser Equal to 4) then do (Item - Create Wunderwaffe at (Center of Region 009 <gen>)) else do (Do nothing)
Any ideas?
 
Level 11
Joined
Mar 17, 2007
Messages
399
The first trigger BAR is [1]? Should that be [2]?

The Second trigger you don't even use the item variables from the map init, I'm not sure if triggering unit has an affect on acquire but if it does I would make a suggestion to change that to hero manipulating item, you're also leaking 4 points.
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
The first trigger is not doing shit atm.

You want something like this:
"Item - Create Item[ItemRandomizer] at (point)"

You indeed have to set Bar to 2 as JaysProjex told but either of these won't fix yourproblem.

Your problem lies in "Random number".
In code it is impossible to make something "Random". That's why people use algorithms to simulate random effects.
Some people use current time in milli/nano seconds to have a different value every time others are using other methods.
I do not know the current best way to create random numbers, neither am I interested in making the method myself.

I have seen this "Random" number shit too when I made an Item Drop System here in WC3.
It is a relief that Random numbers are handled in-game better than in test-executions.

When you run the game instead of testing via the map editor, Random will be "more" random.
 
Level 5
Joined
Dec 11, 2010
Messages
101
I have seen this "Random" number shit too when I made an Item Drop System here in WC3.
It is a relief that Random numbers are handled in-game better than in test-executions.

When you run the game instead of testing via the map editor, Random will be "more" random.

I did not know that "Testing" the map would not work with creating random items. Anyways, thank you both. I got it working :) +rep
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
  • If (ItemRandomiser Equal to 1) then do (Item - Create .357 Magnum at (Center of Region 009 <gen>)) else do (Do nothing)
  • If (ItemRandomiser Equal to 2) then do (Item - Create BAR at (Center of Region 009 <gen>)) else do (Do nothing)
  • If (ItemRandomiser Equal to 3) then do (Item - Create Double-Barrel Shotgun at (Center of Region 009 <gen>)) else do (Do nothing)
  • If (ItemRandomiser Equal to 4) then do (Item - Create Wunderwaffe at (Center of Region 009 <gen>)) else do (Do nothing)

-> Create Item[random numer between 1 and 4]
 
Status
Not open for further replies.
Top