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 havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. 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.

[Trigger] Major problems with random integer numbers

Discussion in 'Triggers & Scripts' started by Paulus, Jan 22, 2014.

  1. Paulus

    Paulus

    Joined:
    Jan 17, 2014
    Messages:
    155
    Resources:
    0
    Resources:
    0
    Hi,

    i'm trying to make a trigger that creates an item on a location depending on the random integer number.

    The trigger
    • map initializinga
      • Events
        • Map initialization
      • Conditions
      • Actions
        • Trigger - Turn off Red ShardsA Barrel1 Dies <gen>
        • Trigger - Turn off Red ShardsA SkeletonGrunt <gen>
        • Trigger - Turn off Red ShardsA Barrel2 Dies <gen>
        • Set RandomitemReda = (Random integer number between 1 and 10)
        • If (RandomitemReda Equal to 5) then do (Item - Create Red Shards at (Center of Red FragtionA <gen>)) else do (If (RandomitemReda Equal to 4) then do (Item - Create Red Shards at (Center of Red FragtionA2 <gen>)) else do (If (RandomitemReda Equal to 3) then do (Trigger - Turn on Red ShardsA Barrel1 Dies <gen>) else do (If (RandomitemReda Equal to 2) then do (Trigger
        • Floating Text - Create floating text that reads (String(RandomitemReda)) above Archmage 0060 <gen> with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency


    The only problem is, that the random number is the same everytime!
    When i put the triggerevent on map initializing, the number is always 10 (highest number between 1-10)
    When i put the triggerevent on 1 sec, i always get number 4
    when i put the triggerevent on random number between 1-4 sec a always get number 3

    Can someone let me why i don't get a random number everytime?
    thx
     
  2. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,612
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    that is a world editor setting. seed something

    edit:
    file>preferences>test map tab>use fixed random seed
     
  3. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,548
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Yes because your RNG is set to the same seed every time.

    Someone forgot to uncheck "fixed seed" from their editor options for map testing.

    Computers are not capable of randomness. They instead use a pseudo random generator which in reality is just a finite sequence with order such that it is as good as random and so large it is impossible to predict. If you set up the sequence at the same place and request the same number ranges from it you will logically get the same answer.

    Adding some human input to request extra random numbers (as happens in normal games) makes predicting the RNG as good as impossible.

    You do not in multiplayer games as the seed is more random (unless a hostbot is used to specifically set the seed).
     
  4. Paulus

    Paulus

    Joined:
    Jan 17, 2014
    Messages:
    155
    Resources:
    0
    Resources:
    0
    Thx man! you're a lifesaver, was going crazing about this :)
     
  5. Paulus

    Paulus

    Joined:
    Jan 17, 2014
    Messages:
    155
    Resources:
    0
    Resources:
    0
    you both are :p
     
  6. DysfunctionaI

    DysfunctionaI

    Joined:
    Mar 6, 2006
    Messages:
    281
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Quick note:

    • Time - Every (Random real number between 1.00 and 10.00) seconds of game time


    That event is run only once, at map init, meaning that it generates a random number for that event, only once.

    So if say, you get a random number of 4, then that event will essentially be:

    • Time - Every 4.00 seconds of game time