Set an integer to a random integer?

Wratox1

Member
Reaction score
22
Hi, i need some help with integers;

I want to set an integer to the value of a random selected integer multiplied by the value of another random selected integer...

Is there anyway to do this?(im not good at jass, so id rather have it in GUI)And this even possible? i cant manage to figure it out:banghead:
 

Komaqtion

You can change this now in User CP.
Reaction score
469
You mean like this ?
Trigger:
  • Random Integer
    • Events
    • Conditions
    • Actions
      • Set Integer[1] = (Random integer number between 1 and 100)
      • Set Integer[2] = (Random integer number between 1 and 100)
      • Set Integer[2] = (Integer[1] * Integer[2])
 

Romek

Super Moderator
Reaction score
963
Trigger:
  • Set SomeInt = ((Random integer number between A and B) x (Random integer number between C and D))
 

Wratox1

Member
Reaction score
22
okay, maybe i wasnt really clear, i want to set a integervariable to a random integervariable multiplied by another random integervariable, or im just stupid and didnt see the answer among your posts...
 

Romek

Super Moderator
Reaction score
963
> Yeah, that's what i did in my post
Well, you just changed it from a division to a multiplication.
And your solution is still quite silly.

Amfie made a little mistake with the operation in #2 - My post is exactly his, with a different operation.

> or im just stupid and didnt see the answer among your posts...
:p
 

Tyrulan

Ultra Cool Member
Reaction score
37
Looks like you've got this one answered. He should be able to figure it out from here.


On a side note: Romek is using "Arithmetic" for his trigger.
(For the Asker)
 

Sajberhippie

New Member
Reaction score
30
No, I think he means something different.
@OP: Is your need to multiply a randomly selected already set integer variable among many integer variables with another of those?
And may I ask why in that case? The only way I could think of that is (quite) dynamic would be to have all the different integers that you choose between not to be different variables but arrays in a single variable and select Variable[random number between 1 and X].
 

Wratox1

Member
Reaction score
22
sajberhippie thats what im looking for ill explain some more and also show my triggers...

Trigger:
  • FirstClueKnights
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set FirstClue5 = (Random integer number between 1 and 5)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FirstClue5 Equal to 1
        • Then - Actions
          • Set RandomPoint = (Random point in FirstClue <gen>)
          • Unit - Create 1 FakeUnit3 for Neutral Passive at RandomPoint facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_RandomPoint)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • FirstClue5 Equal to 2
            • Then - Actions
              • Set RandomPoint = (Random point in FirstClue <gen>)
              • Unit - Create 1 FakeUnit3 for Neutral Passive at RandomPoint facing Default building facing degrees
              • Custom script: call RemoveLocation(udg_RandomPoint)
              • Set RandomPoint = (Random point in FirstClue <gen>)
              • Unit - Create 1 FakeUnit3 for Neutral Passive at RandomPoint facing Default building facing degrees
              • Custom script: call RemoveLocation(udg_RandomPoint)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • FirstClue5 Equal to 3
                • Then - Actions
                  • Set RandomPoint = (Random point in FirstClue <gen>)
                  • Unit - Create 1 FakeUnit3 for Neutral Passive at RandomPoint facing Default building facing degrees
                  • Custom script: call RemoveLocation(udg_RandomPoint)
                  • Set RandomPoint = (Random point in FirstClue <gen>)
                  • Unit - Create 1 FakeUnit3 for Neutral Passive at RandomPoint facing Default building facing degrees
                  • Custom script: call RemoveLocation(udg_RandomPoint)
                  • Set RandomPoint = (Random point in FirstClue <gen>)
                  • Unit - Create 1 FakeUnit3 for Neutral Passive at RandomPoint facing Default building facing degrees
                  • Custom script: call RemoveLocation(udg_RandomPoint)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • FirstClue5 Equal to 4
                    • Then - Actions
                      • Set RandomPoint = (Random point in FirstClue <gen>)
                      • Unit - Create 1 FakeUnit3 for Neutral Passive at RandomPoint facing Default building facing degrees
                      • Custom script: call RemoveLocation(udg_RandomPoint)
                      • Set RandomPoint = (Random point in FirstClue <gen>)
                      • Unit - Create 1 FakeUnit3 for Neutral Passive at RandomPoint facing Default building facing degrees
                      • Custom script: call RemoveLocation(udg_RandomPoint)
                      • Set RandomPoint = (Random point in FirstClue <gen>)
                      • Unit - Create 1 FakeUnit3 for Neutral Passive at RandomPoint facing Default building facing degrees
                      • Custom script: call RemoveLocation(udg_RandomPoint)
                      • Set RandomPoint = (Random point in FirstClue <gen>)
                      • Unit - Create 1 FakeUnit3 for Neutral Passive at RandomPoint facing Default building facing degrees
                      • Custom script: call RemoveLocation(udg_RandomPoint)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • FirstClue5 Equal to 5
                        • Then - Actions
                          • Set RandomPoint = (Random point in FirstClue <gen>)
                          • Unit - Create 1 FakeUnit3 for Neutral Passive at RandomPoint facing Default building facing degrees
                          • Custom script: call RemoveLocation(udg_RandomPoint)
                          • Set RandomPoint = (Random point in FirstClue <gen>)
                          • Unit - Create 1 FakeUnit3 for Neutral Passive at RandomPoint facing Default building facing degrees
                          • Custom script: call RemoveLocation(udg_RandomPoint)
                          • Set RandomPoint = (Random point in FirstClue <gen>)
                          • Unit - Create 1 FakeUnit3 for Neutral Passive at RandomPoint facing Default building facing degrees
                          • Custom script: call RemoveLocation(udg_RandomPoint)
                          • Set RandomPoint = (Random point in FirstClue <gen>)
                          • Unit - Create 1 FakeUnit3 for Neutral Passive at RandomPoint facing Default building facing degrees
                          • Custom script: call RemoveLocation(udg_RandomPoint)
                          • Set RandomPoint = (Random point in FirstClue <gen>)
                          • Unit - Create 1 FakeUnit3 for Neutral Passive at RandomPoint facing Default building facing degrees
                          • Custom script: call RemoveLocation(udg_RandomPoint)
                        • Else - Actions


thats one of them, i have 4 just like this one, but a little longer... so i'll only show the shortest because one has random integer number between 1 and 30, its quite long...

then i have this one:
Trigger:
  • FirstClue
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set FirstClue = (FirstClue1 x FirstClue2)
      • Wait 5.00 seconds
      • Game - Display to (All players) the text: Hi and welcome, tod...
      • Wait 6.00 seconds
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Visibility - Create an initially Enabled visibility modifier for (Picked player) emitting Visibility across FirstClue <gen>
      • Set Visibility = (Last created visibility modifier)
      • Game - Display to (All players) the text: Lets start with som...
      • Countdown Timer - Start Timer as a One-shot timer that will expire in 600.00 seconds
      • Wait 1.50 seconds
      • Floating Text - Create floating text that reads Multiply the number... at (Center of FirstClue <gen>) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Set Floatingtext = (Last created floating text)
      • Wait 10.00 seconds
      • Game - Display to (All players) the text: And when you think ...

and its in this trigger i want to change one thing;
Trigger:
  • Set FirstClue = (FirstClue1 x FirstClue2)

to something like: set FirstClue = (random integervariable x random integervariable)
which means that i want the trigger to set FirstClue to a random picked integervariable of the ones which exists and multipy the value of the picked integer with another random picked variable...

Am i getting my message clear?
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Then you'll probably have to use arrays, and then you can use Random Number between x and y, meaning the lowest array value and the highest.
 

Tyrulan

Ultra Cool Member
Reaction score
37
What's wrong with this?:

Trigger:
  • Set FirstClue = ((Random integer number between 1 and 10) x (Random integer number between 1 and 10))


Or this...

Trigger:
  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • Set FirstClue = (Random integer number between 1 and 3)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FirstClue == 1
        • Then - Actions
          • Set temp_Number = Random Integer Variable 1
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FirstClue == 2
        • Then - Actions
          • Set temp_Number = Random Integer Variable 2
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FirstClue == 3
        • Then - Actions
          • Set temp_Number = Random Integer Variable 3
        • Else - Actions


Arrays are much easier ... lol
 

Wratox1

Member
Reaction score
22
What's wrong with this?:

Trigger:
  • Set FirstClue = ((Random integer number between 1 and 10) x (Random integer number between 1 and 10))


Or this...

Trigger:
  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • Set FirstClue = (Random integer number between 1 and 3)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FirstClue == 1
        • Then - Actions
          • Set temp_Number = Random Integer Variable 1
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FirstClue == 2
        • Then - Actions
          • Set temp_Number = Random Integer Variable 2
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FirstClue == 3
        • Then - Actions
          • Set temp_Number = Random Integer Variable 3
        • Else - Actions


Arrays are much easier ... lol

i don't think that you know what i want... take a look at post #10 and there is what i want...

as for the arrays, i was just curious about if there where any other way than arrays, even if i'm going to use arrays...

Quote:
Originally Posted by Wratox1
*awful code*



Egads! Use a for loop!


Code:
for i = 1 to FirstClue5
pick random point
create 1 unit at random point

how do you mean? do you mean a for each integer loop?
 

Tyrulan

Ultra Cool Member
Reaction score
37
Done trying to solve this problem for you. You're going to have to find a better way of explaining it to me without throwing triggers at me.
 

Wratox1

Member
Reaction score
22
well, the problem is solved, but i just wondered if there where any other methods to solve the problem, both easier and harder, just wanted to know what options i had... But anyway im gonna use arrays...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top