1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The reforging of the races is complete. Come see the 14th Techtree Contest Results.
    Dismiss Notice
  4. It's time to choose your horse in the race - the 32nd Modeling Contest Poll is up!
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Random Item Spawn Problem

Discussion in 'Triggers & Scripts' started by Impereal Gardian, Feb 6, 2015.

  1. Impereal Gardian

    Impereal Gardian

    Joined:
    Dec 11, 2010
    Messages:
    100
    Resources:
    0
    Resources:
    0
    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?
     
  2. JaysProjex

    JaysProjex

    Joined:
    Mar 17, 2007
    Messages:
    418
    Resources:
    4
    Maps:
    4
    Resources:
    4
    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.
     
  3. Wietlol

    Wietlol

    Joined:
    Aug 1, 2013
    Messages:
    4,640
    Resources:
    3
    Spells:
    3
    Resources:
    3
    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.
     
  4. Impereal Gardian

    Impereal Gardian

    Joined:
    Dec 11, 2010
    Messages:
    100
    Resources:
    0
    Resources:
    0
    I did not know that "Testing" the map would not work with creating random items. Anyways, thank you both. I got it working :) +rep
     
  5. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,526
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    Go to WorldEditor > File > Preferences > Test Map > Use Fixed Random Seed

    Make sure that the Use Fixed Random Seed is off.
     
  6. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,175
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    -> Create Item[random numer between 1 and 4]
     
  7. Wietlol

    Wietlol

    Joined:
    Aug 1, 2013
    Messages:
    4,640
    Resources:
    3
    Spells:
    3
    Resources:
    3
    So not copied :p

    (sorry bro, just had to say it)

    Putting it in a value makes it easier to modify too, but you can indeed create the random one in that create method too if you want.