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. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  4. Dismiss Notice
  5. The Highway to Hell has been laid open. Come along and participate in the 5th Special Effect Contest.
    Dismiss Notice
  6. 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.

Pick a Random Integer

Discussion in '"Graveyard"' started by kuyanutay, Nov 13, 2011.

  1. kuyanutay

    kuyanutay

    Joined:
    Dec 11, 2010
    Messages:
    2
    Resources:
    0
    Resources:
    0
    How to Use "Pick a Random Integer"


    You may have seen this option in GUI before. Maybe that's why you viewed this tutorial. It appears in Math, and it is called Random Number.

    With this function, you can have random events, numbers, or rewards(you can use something else for this) appearing in your map.

    To use this function, you must have a variable, which can be created at the Variable Editor. The variable must be an INTEGER.

    After completing the task, you may proceed to step 1.

    Step 1

    Create the desired event. For this tutorial, we will use Time - Periodic Event.

    • Random Integer
      • Events
        • Time - Every 2.00 seconds of game time
      • Conditions
      • Actions


    You may also add a condition. If you want.

    Step 2

    Now set the variable. We will use E1 for the tutorial.

    • Random Integer
      • Events
        • Time - Every 2.00 seconds of game time
      • Conditions
      • Actions
        • Set E1 = (Random integer number between 1 and 2)


    Once that is done, we will go to the tricky part.

    Step 3

    Now, you must create actions corresponding to the picked integers.

    Create a new ACTION, then choose If Then Else Multiple Functions.

    The "Then" will be the action corresponding to 1.

    We will use "Hello World" as the "Then" for 1.

    • Random Integer
      • Events
        • Time - Every 2.00 seconds of game time
      • Conditions
      • Actions
        • Set E1 = (Random integer number between 1 and 2)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • E1 Equal to 1
          • Then - Actions
            • Game - Display to (All players) the text: Hello World!
          • Else - Actions


    For the integer 2, we will repeat these steps.

    For this tutorial, we will use Hello Azeroth!

    Since we are done with the trigger, put Do Nothing on the last Else.

    The finished trigger will look like this:

    • Random Integer
      • Events
        • Time - Every 2.00 seconds of game time
      • Conditions
      • Actions
        • Set E1 = (Random integer number between 1 and 2)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • E1 Equal to 1
          • Then - Actions
            • Game - Display to (All players) the text: Hello World!
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • E1 Equal to 2
              • Then - Actions
                • Game - Display to (All players) the text: Hello Azeroth!
              • Else - Actions
                • Do nothing

    Before you test out the map, go to File > Preferences > Test Map and disable Use Fixed Random Seed
    Go check out the map, to see if you really got it right.
    ---------------------------------------
    Have fun with random integers!
     
  2. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,181
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    This is how you should do the triggers:

    Triggers

    50% chance to do something:
    • Random Integer
      • Events
        • Time - Every 2.00 seconds of game time
      • Conditions
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Random integer number between 1 and 2) Equal to 1
          • Then - Actions
            • Game - Display to (All players) the text: Hello World!
          • Else - Actions


    50%/50% chance:
    • Random Integer
      • Events
        • Time - Every 2.00 seconds of game time
      • Conditions
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Random integer number between 1 and 2) Equal to 1
          • Then - Actions
            • Game - Display to (All players) the text: Hello World!
          • Else - Actions
            • Game - Display to (All players) the text: Hello Azeroth!



    • Random Integer
      • Events
        • Time - Every 2.00 seconds of game time
      • Conditions
      • Actions
        • Set E1 = (Random integer number between 1 and 3)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • E1 Equal to 1
          • Then - Actions
            • Game - Display to (All players) the text: Hello World!
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • E1 Equal to 2
              • Then - Actions
                • Game - Display to (All players) the text: Hello Azeroth!
              • Else - Actions
                • Game - Display to (All players) the text: It was the third option


    This is quite simple tutorial, and might not need a tutorial at all.
     
    Last edited: Nov 20, 2011
  3. busterkomo

    busterkomo

    Joined:
    Jun 17, 2007
    Messages:
    1,423
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Maker, your third trigger doesn't even make sense. The last else block can never be reached.
     
  4. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    Yes, this is a bit too basic of a tutorial. For me to accept a tutorial about random integers specifically, it would need to discuss seeds and weights.

    We already have tutorials for chances of doing things. :)
     
  5. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    It can be a real. You'd use (Random real number between x and y).

    • Do Nothing


    ._.
    call MakeGUIUsersCrash()
     
  6. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    Its too simple I guess...

    The only time I think that someone needs a tutorial for this is when:

    1)He does not know what a random number is
    2)He does not know how to use if-then-elses
     
  7. -Kobas-

    -Kobas-

    Joined:
    Jan 17, 2010
    Messages:
    5,894
    Resources:
    28
    Icons:
    1
    Tools:
    2
    Maps:
    10
    Spells:
    4
    Template:
    5
    Tutorials:
    6
    Resources:
    28
    I think, that it can be reached.

    E1 can be 1 or 2 or 3 right,
    Code (vJASS):

    if E1 equal to  1 then
    //xxxx
    elseif E1 equal to 2 then
    //xxxx
    else (Where we check is E1 equal to 3 or any other number except 1 and 2)
    //xxx
    endif
     


    Jass tags to make this look like code.
     
  8. watermelon_1234

    watermelon_1234

    Joined:
    Nov 18, 2007
    Messages:
    1,066
    Resources:
    10
    Spells:
    9
    JASS:
    1
    Resources:
    10
    ^
    I assume he edited the trigger.

    Anyway, I agree with the others that this is too simple to be a tutorial.
     
  9. -Kobas-

    -Kobas-

    Joined:
    Jan 17, 2010
    Messages:
    5,894
    Resources:
    28
    Icons:
    1
    Tools:
    2
    Maps:
    10
    Spells:
    4
    Template:
    5
    Tutorials:
    6
    Resources:
    28
    Oh, missed that.
    Btw way to simple.
     
  10. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    It has been a month without updates so I'm going to graveyard this for now.

    Let me know if you want to update it to include more complex things, but otherwise it is off to the graveyard.