• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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 12
Joined
Mar 17, 2007
Messages
412
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,657
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,240
  • 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