• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How do I match a number to a set list of numbers?

Status
Not open for further replies.
Level 12
Joined
Jan 30, 2009
Messages
1,067
Hey, everyone.

EDIT3: Well, two problems as of 11/11/2010. Would be nice to have some answers, :)

EDIT2: Link to the current problem if you wish to skip the rest of it.

EDIT: Whoops, I forgot to change the thread title after I changed what my question is... D: Fixed.

I'm creating a dice roll system with 6 dice currently. atm I've got:

  • Roll Dice
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (==) Roll Dice
    • Actions
      • Trigger - Turn off (This trigger)
      • Set Dice_Roll[1] = (Random integer number between 1 and 6)
      • Set Dice_Result[1] = Dice_Result[1]
      • Set Dice_Roll[2] = (Random integer number between 1 and 6)
      • Set Dice_Result[2] = Dice_Result[2]
      • Set Dice_Roll[3] = (Random integer number between 1 and 6)
      • Set Dice_Result[3] = Dice_Result[3]
      • Set Dice_Roll[4] = (Random integer number between 1 and 6)
      • Set Dice_Result[4] = Dice_Result[4]
      • Set Dice_Roll[5] = (Random integer number between 1 and 6)
      • Set Dice_Result[5] = Dice_Result[5]
      • Set Dice_Roll[6] = (Random integer number between 1 and 6)
      • Set Dice_Result[6] = Dice_Result[6]
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
        • Else - Actions
      • Wait 1.50 seconds
      • Game - Display to (All players) for 30.00 seconds the text: ((Name of (Triggering player)) + (has rolled: |cffffcc00 + ((String(Dice_Roll[1])) + (|r, |cffffcc00 + ((String(Dice_Roll[2])) + (|r, |cffffcc00 + ((String(Dice_Roll[3])) + (|r, |cffffcc00 + ((String(Dice_Roll[4])) + (|r, |cffffcc00 + ((String(Dice_Roll[5]))
      • Game - Display to (All players) for 30.00 seconds the text: Unknown
      • Game - Display to (All players) for 30.00 seconds the text: ((Name of (Triggering player)) + now has 30 seconds to choose which dice they wish to keep.)
      • Trigger - Turn on Select to keep <gen>
      • Wait 30.00 seconds
      • Trigger - Turn off Select to keep <gen>
      • Game - Display to (All players) the text: ((Name of (Triggering player)) + has failed to select their dice in time. Next turn.)
Now, that If/Then/Else is where I got stuck. I want to check the numbers that were rolled, then compare them to a set list of numbers to see if they don't match. Something like:

  • No 1
  • No 5
  • No 1, 1, 1
  • No 2, 2, 2
  • No 3, 3, 3
  • No 4, 4, 4
  • No 5, 5, 5
  • No 6, 6, 6
  • No 1, 2, 3, 4, 5, 6.
Although, I guess, looking back, that the minimum I'd need is:

  • No 1
  • No 5
  • No 2, 2, 2
  • No 3, 3, 3
  • No 4, 4, 4
  • No 6, 6, 6
Since the others would be covered by the first two.

Also, I have one other, generic question.

What would happen if I have "Trigger - Turn off Select to keep <gen>" set after a timer like I have it here, and it already be off before that time has expired? Basically, what happens if I turn off a trigger that's already turned itself off? I don't think anything weird would happen, but I'd like to be sure.
 
Last edited:
Level 15
Joined
Oct 16, 2010
Messages
941
What would happen if I have "Trigger - Turn off Select to keep <gen>" set after a timer like I have it here, and it already be off before that time has expired? Basically, what happens if I turn off a trigger that's already turned itself off? I don't think anything weird would happen, but I'd like to be sure.

Nothing happens, it won't cause you any problems to do that.

I'm afraid I didn't quite follow your first problem with the dice, could you explain what your trying to do again :0?
 
you can multiple conditions...


for the no 1

  • If-Then-Else
    • If - Conditions
      • Dice_Roll[1] is not equal to 1
      • Dice_Roll[2] is not equal to 1
      • Dice_Roll[4] is not equal to 1
      • Dice_Roll[5] is not equal to 1
      • Dice_Roll[6] is not equal to 1
      • Dice_Roll[7] is not equal to 1
      • Then - Actions
for the other's you can check how many times a number showed up... and then use that count into the if-then-else...
example

  • Actions
    • Loop - For Each integer A from 1 to 6 do
      • do - Actions
        • If-Then-Else
          • If - Conditions
            • Dice_Roll[Integer A] is equal to 2
          • Then - Actions
            • Set CounterOf2 = CounterOf2 + 1
      • If-Then-Else
        • If - Conditions
          • CounterOf2 is equal to 3
        • Then - Actions
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
you can multiple conditions...


for the no 1

  • If-Then-Else
    • If - Conditions
      • Dice_Roll[1] is not equal to 1
      • Dice_Roll[2] is not equal to 1
      • Dice_Roll[4] is not equal to 1
      • Dice_Roll[5] is not equal to 1
      • Dice_Roll[6] is not equal to 1
      • Dice_Roll[7] is not equal to 1
      • Then - Actions
for the other's you can check how many times a number showed up... and then use that count into the if-then-else...
example

  • Actions
    • Loop - For Each integer A from 1 to 6 do
      • do - Actions
        • If-Then-Else
          • If - Conditions
            • Dice_Roll[Integer A] is equal to 2
          • Then - Actions
            • Set CounterOf2 = CounterOf2 + 1
      • If-Then-Else
        • If - Conditions
          • CounterOf2 is equal to 3
        • Then - Actions
First of all, do I not need to have Dice_Result variable to check for the numbers? Cause if not, then I'm gonna get rid of it.

And in that case, since I also need to do it with 5 as well, I'm thinking something like this:

  • Roll Dice
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (==) Roll Dice
    • Actions
      • Trigger - Turn off (This trigger)
      • Set Dice_Roll[1] = (Random integer number between 1 and 6)
      • Set Dice_Roll[2] = (Random integer number between 1 and 6)
      • Set Dice_Roll[3] = (Random integer number between 1 and 6)
      • Set Dice_Roll[4] = (Random integer number between 1 and 6)
      • Set Dice_Roll[5] = (Random integer number between 1 and 6)
      • Set Dice_Roll[6] = (Random integer number between 1 and 6)
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Dice_Roll[1] Not equal to (!=) 1
            • Dice_Roll[2] Not equal to (!=) 1
            • Dice_Roll[3] Not equal to (!=) 1
            • Dice_Roll[4] Not equal to (!=) 1
            • Dice_Roll[5] Not equal to (!=) 1
            • Dice_Roll[6] Not equal to (!=) 1
          • Then - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Dice_Roll[1] Not equal to (!=) 5
                • Dice_Roll[2] Not equal to (!=) 5
                • Dice_Roll[3] Not equal to (!=) 5
                • Dice_Roll[4] Not equal to (!=) 5
                • Dice_Roll[5] Not equal to (!=) 5
                • Dice_Roll[6] Not equal to (!=) 5
              • Then - Actions
                • Do Multiple ActionsFor each (Integer A) from 1 to 6, do (Actions)
                  • Loop - Actions
                    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • Dice_Roll[(Integer A)] Equal to (==) 2
                      • Then - Actions
                        • Set CounterOf2 = (CounterOf2 + 1)
                      • Else - Actions
                        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • If - Conditions
                            • Dice_Roll[(Integer A)] Equal to (==) 3
                          • Then - Actions
                            • Set CounterOf3 = (CounterOf3 + 1)
                          • Else - Actions
                            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                              • If - Conditions
                                • Dice_Roll[(Integer A)] Equal to (==) 4
                              • Then - Actions
                                • Set CounterOf4 = (CounterOf4 + 1)
                              • Else - Actions
                                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                  • If - Conditions
                                    • Dice_Roll[(Integer A)] Equal to (==) 6
                                  • Then - Actions
                                    • Set CounterOf6 = (CounterOf6 + 1)
                                  • Else - Actions
              • Else - Actions
                • Trigger - Run FAIL <gen> (checking conditions)
                • Skip remaining actions
          • Else - Actions
      • Wait 1.50 seconds
      • Game - Display to (All players) for 30.00 seconds the text: ((Name of (Triggering player)) + (has rolled: |cffffcc00 + ((String(Dice_Roll[1])) + (|r, |cffffcc00 + ((String(Dice_Roll[2])) + (|r, |cffffcc00 + ((String(Dice_Roll[3])) + (|r, |cffffcc00 + ((String(Dice_Roll[4])) + (|r, |cffffcc00 + ((String(Dice_Roll[5]))
      • Game - Display to (All players) for 30.00 seconds the text: Unknown
      • Game - Display to (All players) for 30.00 seconds the text: ((Name of (Triggering player)) + now has 30 seconds to choose which dice they wish to keep.)
      • Trigger - Turn on Select to keep <gen>
      • Wait 30.00 seconds
      • Trigger - Turn off Select to keep <gen>
      • Game - Display to (All players) the text: ((Name of (Triggering player)) + has failed to select their dice in time. Next turn.)
But I can't help but think there's a way to clean that up...

For instance, something like:
  • Do Multiple ActionsFor each (Integer A) from 1 to 6, do (Actions)
    • Loop - Actions
      • Set Dice_Roll[(Integer A)] = (Random integer number between 1 and 6)
instead of setting them all individually? Could that work? And all those conditions in the If/Then/Else... o_O

EDIT: Fixed this trigger. Not that it matter, xD
 
Last edited:
oh, my bad... It should be Dice_Result... you can loop the setting but not the conditions... without changing those if-then completely...

you can loop them and set the result into a boolean

  • For Each Integer A from 1 to 6
    • Do - Actions
      • If Then Else
        • If - Conditions
          • Dice_Result[Integer A] not equal to 1
        • Then - Actions
          • Set Not1 = true
        • Else - Action
          • Set Not1 = false
      • If Then Else
        • If - Conditions
          • Dice_Result[Integer A] not equal to 5
        • Then - Actions
          • Set Not5 = true
        • Else - Action
          • Set Not5 = false
and do this for all the others and then just check the booleans at the end...
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
But then Dice_Result wouldn't be needed anymore, right? So wouldn't it work with Dice_Roll?

EDIT: Holy crap, just noticed I set the wrong variable when I was making it, I had actually meant to set it as Dice_Roll, not Dice_result, to attempt to show that I was doing it without Dice_result. Guess that failed.
 
well since you did this:

Set Dice_Roll[1] = (Random integer number between 1 and 6)
Set Dice_Roll[2] = (Random integer number between 1 and 6)
Set Dice_Roll[3] = (Random integer number between 1 and 6)
Set Dice_Roll[4] = (Random integer number between 1 and 6)
Set Dice_Roll[5] = (Random integer number between 1 and 6)
Set Dice_Roll[6] = (Random integer number between 1 and 6)

you dont need dice result anymore, you dont even set it...
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
well since you did this:

Set Dice_Roll[1] = (Random integer number between 1 and 6)
Set Dice_Roll[2] = (Random integer number between 1 and 6)
Set Dice_Roll[3] = (Random integer number between 1 and 6)
Set Dice_Roll[4] = (Random integer number between 1 and 6)
Set Dice_Roll[5] = (Random integer number between 1 and 6)
Set Dice_Roll[6] = (Random integer number between 1 and 6)

you dont need dice result anymore, you dont even set it...

Yeah, cuz I removed it, thinking it wasn't needed. And like you say, I don't need it, so why bother? :D

EDIT: Here's what I ended up with. I seem to be remembering reading somewhere not to put waits inside loops. Got a bad feeling, :p

  • Roll Dice
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (==) Roll Dice
    • Actions
      • Trigger - Turn off (This trigger)
        • Do Multiple ActionsFor each (Integer A) from 1 to 6, do (Actions)
          • Loop - Actions
            • Set Dice_Roll[(Integer A)] = (Random integer number between 1 and 6)
      • Wait 1.50 seconds
      • Game - Display to (All players) for 30.00 seconds the text: ((Name of (Triggering player)) + (has rolled: |cffffcc00 + ((String(Dice_Roll[1])) + (|r, |cffffcc00 + ((String(Dice_Roll[2])) + (|r, |cffffcc00 + ((String(Dice_Roll[3])) + (|r, |cffffcc00 + ((String(Dice_Roll[4])) + (|r, |cffffcc00 + ((String(Dice_Roll[5]))
      • Game - Display to (All players) for 30.00 seconds the text: <Empty String>
        • Do Multiple ActionsFor each (Integer A) from 1 to 6, do (Actions)
          • Loop - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Dice_Roll[(Integer A)] Not equal to (!=) 1
              • Then - Actions
                • Set Not1 = True
              • Else - Actions
                • Set Not1 = False
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Dice_Roll[(Integer A)] Not equal to (!=) 5
              • Then - Actions
                • Set Not5 = True
              • Else - Actions
                • Set Not5 = False
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Dice_Roll[(Integer A)] Equal to (==) 2
              • Then - Actions
                • Set CounterOf2 = (CounterOf2 + 1)
              • Else - Actions
                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Dice_Roll[(Integer A)] Equal to (==) 3
                  • Then - Actions
                    • Set CounterOf3 = (CounterOf3 + 1)
                  • Else - Actions
                    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • Dice_Roll[(Integer A)] Equal to (==) 4
                      • Then - Actions
                        • Set CounterOf4 = (CounterOf4 + 1)
                      • Else - Actions
                        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • If - Conditions
                            • Dice_Roll[(Integer A)] Equal to (==) 6
                          • Then - Actions
                            • Set CounterOf6 = (CounterOf6 + 1)
                          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Not1 Equal to (==) True
            • Not5 Equal to (==) True
            • CounterOf2 Less than (<) 3
            • CounterOf3 Less than (<) 3
            • CounterOf4 Less than (<) 3
            • CounterOf6 Less than (<) 3
          • Then - Actions
            • Trigger - Run FAIL <gen> (checking conditions)
            • Skip remaining actions
          • Else - Actions
      • Game - Display to (All players) for 30.00 seconds the text: ((Name of (Triggering player)) + now has 30 seconds to choose which dice they wish to keep.)
      • Trigger - Turn on Select to keep <gen>
      • Wait 30.00 seconds
      • Trigger - Turn off Select to keep <gen>
      • Game - Display to (All players) the text: ((Name of (Triggering player)) + has failed to select their dice in time. Next turn.)
Looks MUCH better now. Thanks a ton.

EDIT2: Okay, so, just noticed something I overlooked. I need to spawn units based on the numbers rolled. And I need there to be one unit per rolled die. Now, would I be able to do this with the loop roll I have set up here, or will I need to revert back to single roll and spawn the unit that way? Also, and this is the most important part, how do I spawn them easily? Do I need to do 6x If/Then/Else for each roll, or is there a simpler way? Thanks in advance! I'm going to bed now. :)

EDIT3: Fixed the trigger. Removed the loop. Thanks again.
 
Last edited:
if you just need to create 1 per number that showed on the die per player... you can just add simple loops since you dont overwrite Dice_Roll[] along the code only at the start

Note: the if-then-else is made assuming only 6 players
  • Player Group - Pick Every Player in All Players and Do
    • Do - Actions
      • If-Then-Else
        • If - conditions
          • If - Player Number of PickedPlayer is less than or equal to 6
        • Then - Actions
          • For Each Integer Variable Loop from 1 to Dice_Roll[PlayerNumber of PickedPlayer] do Actions
            • Do - Actions
              • Unit - Create unit
BTW, you dont need to loop the last part of the trigger, its senseless... (the one that shows FAIL)
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
if you just need to create 1 per number that showed on the die per player... you can just add simple loops since you dont overwrite Dice_Roll[] along the code only at the start

Note: the if-then-else is made assuming only 6 players
  • Player Group - Pick Every Player in All Players and Do
    • Do - Actions
      • If-Then-Else
        • If - conditions
          • If - Player Number of PickedPlayer is less than or equal to 6
        • Then - Actions
          • For Each Integer Variable Loop from 1 to Dice_Roll[PlayerNumber of PickedPlayer] do Actions
            • Do - Actions
              • Unit - Create unit
BTW, you dont need to loop the last part of the trigger, its senseless... (the one that shows FAIL)

You're right, I don't need to loop that. I was cnping a lot, and must have missed that. Will fix.

As for the unit spawn, I have 6 different units to spawn. there's a "Rolled 1" a "Rolled 2" all through 6. It's a spawn based on the number rolled. The player who rolled doesn't matter cuz they all take turns.

I need something like:
  • Actions
  • IF
  • Dice_Roll[1] = 1
  • THEN
  • Unit - Create etc.
  • IF
  • Dice_Roll[2] = 2
  • THEN
  • Unit - Create
  • ELSE
  • ELSE
  • IF
  • Dice_Roll[1] = 2
Kinda like that. But I was thinking, is there a simpler way of doing that?
 
You're right, I don't need to loop that. I was cnping a lot, and must have missed that. Will fix.

As for the unit spawn, I have 6 different units to spawn. there's a "Rolled 1" a "Rolled 2" all through 6. It's a spawn based on the number rolled. The player who rolled doesn't matter cuz they all take turns.

I need something like:
IF
Dice_Roll[1] = 1
THEN
Unit - Create etc.
IF
Dice_Roll[2] = 2
THEN
Unit - Create
ELSE
ELSE
IF
Dice_Roll[1] = 2

Kinda like that. But I was thinking, is there a simpler way of doing that?
there is:

1) Create a UnitType array
2) On map init save every UnitType that can be spawned into the array
-be sure to set the right unit to the right index
3)on your trigger just use the unit-type array
Unit - Create 1 UnitTypeArray[Dice_Roll[PlayerNumberOfPickedPlayer]] for Picked Player blahblah
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
Unit - Create 1 UnitTypeArray[Dice_Roll[PlayerNumberOfPickedPlayer]] for Picked Player blahblah

Create 1 UnitType[Dice_Roll[PlayerNumberOfPickedPlayer]] Where is Player number of picked player coming from? That'll give me the result of from rolling 6 dice, say Dice 2 rolled a 3, it would spawn a "Rolled 3" unit in the "Dice 3" region, and if Dice 5 was a 1, it would spawn a "Rolled 1" unit in "Dice 5" region? I don't understand where that brings in [PlayerNumberOfPickedPlayer] from. Cause this is all happening in turns, it's a game of dice.

Sorry for all the questions, I just got confused there. The previous post's fail trigger was supposed to be something more like this:

  • Spawn
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Dice_Roll[1] Equal to (==) 1
        • Then - Actions
          • Unit - Create 1 Rolled 1 (Male) for (Triggering player) at (Center of Dice1 <gen>) facing Default building facing (270.0) degrees
          • Set Dice_Roll[1] = 0
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Dice_Roll[2] Equal to (==) 1
              • Then - Actions
                • Unit - Create 1 Rolled 1 (Male) for (Triggering player) at (Center of Dice2 <gen>) facing Default building facing (270.0) degrees
                • Set Dice_Roll[2] = 0
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                    • Then - Actions
                    • Else - Actions
              • Else - Actions
                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                  • Then - Actions
                  • Else - Actions
        • Else - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Dice_Roll[1] Equal to (==) 2
            • Then - Actions
              • Unit - Create 1 Rolled 2 (Female) for (Triggering player) at (Center of Dice1 <gen>) facing Default building facing (270.0) degrees
              • Set Dice_Roll[1] = 0
                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                  • Then - Actions
                  • Else - Actions
            • Else - Actions
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                • Then - Actions
                • Else - Actions
In order to cycle through all the possibilities.... Which is a lot of them.
 
remember the Player Group Loop that I used to create units posted above? 4 posts from yours...

replace the create unit there with the new create unit I posted... ^_^

ofc if you wont use that loop, use other ways.... if you know which player runs the dice, just use his player number...

based on the above post, change the PickedPlayer to TriggeringPlayer
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
Oh, now I understand. Problem is, it's up to 8 players, :(

But then could I not do something like
  • Do Multiple ActionsFor each (Integer Dice_Roll[(Integer A)]) from 1 to 6, do (Actions)
    • Loop - Actions
I'm not sure how to go about doing that though since theres:

6 Dice.
6 Regions (1 per Dice_Roll index)
6 different units to be spawned depending on results of dice.
 
Oh, now I understand. Problem is, it's up to 8 players, :(

But then could I not do something like
  • Do Multiple ActionsFor each (Integer Dice_Roll[(Integer A)]) from 1 to 6, do (Actions)
    • Loop - Actions
I'm not sure how to go about doing that though since theres:

6 Dice.
6 Regions (1 per Dice_Roll index)
6 different units to be spawned depending on results of dice.

Why Loop From Dice_Roll[] to 6?

It will work for any player number... because it just uses the Dice_Roll[] of the player... and Dice_Roll[] will always be between 1-6 no matter how many player is there... now I'm the one getting confused...

how/when will you exactly call the createunit function?

is it after the dice trigger you posted above? if yes then just use the player group loop I posted plus this:

modify the Condition: PlayerNumber of PickedPlayer is less than or equal to 8...
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
I think i found a way how to do this, thanks to my roommate. I'll post the result in a couple mins.

EDIT: Okay, not quite gonna work... I think I need a Region Variable Array for this to work.

  • Roll Dice
    • Do Multiple ActionsFor each (Integer A) from 1 to 6, do (Actions)
      • Loop - Actions
        • Set Dice_Roll[(Integer A)] = (Random integer number between 1 and 6)
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Dice_Roll[(Integer A)] Equal to (==) 1
            • Then - Actions
              • Unit - Create 1 Rolled 1 (Male) for (Triggering player) at (Center of Dice1 <gen>) facing Default building facing (270.0) degrees
              • Set Dice_Roll[1] = 0
            • Else - Actions
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
Let me explain in detail then. I was trying not to make a wall of text, but I will now.

For each dice rolled Dice_Roll[1-6], there will be a corresponding unit spawned. This will be 6 units spawned more or less simultaneously, depending on the result.

There's 6 units:

  • Rolled 1
  • Rolled 2
  • Rolled 3
  • Rolled 4
  • Rolled 5
  • Rolled 6
Each unit corresponds to it's number. Here, then, is a sample roll in which the player has failed.

  • Dice_Roll[1] = 6
  • Dice_Roll[2] = 3
  • Dice_Roll[3] = 3
  • Dice_Roll[4] = 2
  • Dice_Roll[5] = 6
  • Dice_Roll[6] = 4
Now, what happens then is there's a visible result of these rolls. So, what ends up happening, is there's 6 regions.

  • Dice1
  • Dice2
  • Dice3
  • Dice4
  • Dice5
  • Dice6
Now, this corresponds to the roll number.

  • Dice1 = result of Dice_Roll[1]
  • Dice2 = result of Dice_Roll[2]
  • Dice3 = result of Dice_Roll[3]
  • Dice4 = result of Dice_Roll[4]
  • Dice5 = result of Dice_Roll[5]
  • Dice6 = result of Dice_Roll[6]
That result is one of the units, as I posted above. Here's the end result of the earlier example:

  • Region Dice1 has a unit called "Rolled 6" spawned in it.
  • Region Dice2 has a unit called "Rolled 3" spawned in it.
  • Region Dice3 has a unit called "Rolled 3" spawned in it.
  • Region Dice4 has a unit called "Rolled 2" spawned in it.
  • Region Dice5 has a unit called "Rolled 6" spawned in it.
  • Region Dice6 has a unit called "Rolled 4" spawned in it.
That is the end result of all of this rolling. In this example, the player has failed their roll (No 1s, 5s, or 3-of-a-kind numbers), and thus they will end up ending their round, setting their Temp_Score to 0, making them gain no points that turn.

TBH, I didn't want to disclose all that much info, but I guess it doesn't really matter anymore. This is Farkle, a dice game. :)
 
I dont really need all that, what I want to know is how will you execute those, meaning the events and such... example: what event fires the Dice rolling etc...

so the units are just for aesthethics? and not really usable?

from my understanding, the dice rolling up to the unit creation will only happen in one trigger right? if its the trigger you posted way back, then just follow my earlier posts...

but replace the PlayerGroup Loop, with this
  • For Each Integer Any from 1 to 6
    • Do - Actions
      • Unit - CreateUnit(UnitTypeArray[Dice_Roll[Any]] for TriggeringPlayer at Center of RegionArray[Dice_Roll[Any]] blahblah
note, you must use a RegionArray to simplify things (the point leaks by the way)

and place it before the If-Then-Else that has the message FAILED...
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
There's an ability called Roll Dice which when used executes the trigger.

The units that are spawned (Rolled 1-6) have an ability on them called "Keep This Die" which then sets aside that unit into the hold section. Then upon rerolls, only the ones left in the first section will be rerolled.

For instance, say I rolled a: 1, 3, 3, 5, 2, 6. I want to keep the 1 and the 5. I select those, and hit Keep This Die. Then what happens next time I roll, is I roll the number of remaining dice, which in this case is 4. Then that keeps going till the player decides to hold and take the points, fails, or successfully holds all 6 dice legally gaining points. If they use all 6, they have "Hot Dice" and are able to more or less start from the beginning, and reroll all 6 dice.
 
so the event is Unit - starts the effect of an ability? if that so, replace TriggeringPlayer from my above post to OwnerOfTriggeringUnit

EDIT!!!!

relooked at your trigger... just add this line to the end of you IntegerA Loop


Unit - CreateUnit(UnitTypeArray[Dice_Roll[IntegerA]] for TriggeringPlayer at Center of RegionArray[Dice_Roll[IntegerA]] blahblah
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
That's what I was looking for (I think)! Thanks a lot, Adiktuz. I'm gonna make said changes and test it out.

I don't need the IF/Then/Else anymore then, I'm assuming. :)
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
Never mind. I removed it, I don't even know why I said anything about it.

Anyway, now I have an issue with my Roller, he doesn't have the ability I've given to him. I think I broke the ability, lol.

I'll try remaking the dummy spell, ><
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
Well. It spawned the units correctly!

Just didn't spawn them in the right PLACE.

They all spawned on top of where I have placed Green at. I'm not sure how THAT happened, though.

EDIT: NVM. I forgot to set the region array. That seemed to fix the issue. One problem though, the units of the same type seem to spawn in the same region. I'll test it again to be sure.

EDIT2: Yeah, what this is doing is putting the unit of that type on the type of region corresponding to it, instead of the region of the dice roll itself.

I rolled a 6, 6, 1, 4, 6, 6 in the screenshot below (In that order) and they spawned with a Rolled 1 in Region 1, a Rolled 4 in Region 4, and 4 Rolled 6's in Region 6.
 

Attachments

  • WC3ScrnShot_103010_125640_01.tga
    4.9 MB · Views: 70
okay... though I hate it when people post .tga... coz I need to open them in photoshop... ^_^... checking... does it have comments on what it should be?

EDIT: so they're not spawning on the right place? maybe there's a problem on the region settings...

what trigger did you use on the creation?

oh I know!!!

Dont use RegionArray[Dice_Roll[IntegerA]] use this RegionArray[IntegerA]
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
Sorry bout the tga, I forgot to attach it to the post. >.<

I have this:
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Rolled_Units[1] = Rolled 1 (Male)
      • Set Rolled_Units[2] = Rolled 2 (Female)
      • Set Rolled_Units[3] = Rolled 3
      • Set Rolled_Units[4] = Rolled 4 (Female)
      • Set Rolled_Units[5] = Rolled 5 (Male 2)
      • Set Rolled_Units[6] = Rolled 6 (Male)
      • Set Rolled_Region[1] = Dice1 <gen>
      • Set Rolled_Region[2] = Dice2 <gen>
      • Set Rolled_Region[3] = Dice3 <gen>
      • Set Rolled_Region[4] = Dice4 <gen>
      • Set Rolled_Region[5] = Dice5 <gen>
      • Set Rolled_Region[6] = Dice6 <gen>
And it's sending all rolls of 6 to Rolled_Region[6] instead of just sending Dice_Roll[6] to Region 6. Even though this way isn't too terrible, it's VERY easy to see what you got, anyway, lol.
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
That worked! Thanks once again.

Now I have to fix this broke dummy spell deal, and I can get this up and running, thanks a lot. You get a huge mention in the credits.
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
Okay I fixed the Dummy Spell issue, I think.

Anyway, my new problem is that I'm trying to set it up so that if certain conditions aren't met (Dice being held aren't scoring dice), that they aren't able to roll again (Cause that'd be against the rules).

So for a little info, I need to empty the held dice if there's ANY die in there that doesn't match a score-type.

If the die is a 1 or a 5, regardless of how many, they can stay.
If the die is a 2, 3, 4, or 6, if there is less than 3 of ANY of them, they need to be removed.
UNLESS, There's exactly 1 of EACH number (1, 2, 3, 4, 5, 6; A Straight), which is also acceptable. I tried to do this, but...it seriously looks wrong, and I can't seem to think of the proper way to do this.



Next thing needed is that if the conditions are met (All dice in the hold area are scoring dice (Straight, Any 1, Any 5, 3+ of ANY same dice), it will allow the roll trigger to run. Problem is, I've got this set to run when you try to use the Roll trigger. So...I'm not sure how to handle that. I tried, but once again, it doesn't look right.

Lastly, if the conditions AREN'T met, I want to take all the units that are in the Hold area, and put them back where they were originally spawned (In the Roll area), and emit a message explaining the problem. You'll notice I didn't add the message yet, cause I haven't gotten to it yet, but that's the easy part, so, :p

  • Next Roll
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (==) Roll Dice
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Multiple ConditionsOr - Any (Conditions) are true
            • Conditions
              • Units_in_HeldDice Greater than (>) 0
              • Held_NumberOf1 Greater than or equal to (>=) 1
              • Held_NumberOf2 Greater than or equal to (>=) 3
              • Held_NumberOf3 Greater than or equal to (>=) 3
              • Held_NumberOf4 Greater than or equal to (>=) 3
              • Held_NumberOf5 Greater than or equal to (>=) 1
              • Held_NumberOf6 Greater than or equal to (>=) 3
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Trigger - Turn on Roll Dice <gen>
          • Trigger - Run Roll Dice <gen> (ignoring conditions)
        • Else - Actions
          • Set TempGroup_HeldDice = (Units in All Held Dice <gen>)
          • Unit Group - Pick every unit in TempGroup_HeldDice and do (Actions)
            • Loop - Actions
Furthermore, here's the regular Roll Dice trigger, from the other page (With an edit that I did later, after realizing it needed changed to be used again) in case it helps:
  • Roll Dice
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (==) Roll Dice
    • Actions
      • Trigger - Turn off (This trigger)
        • Do Multiple ActionsFor each (Integer A) from 1 to Number_of_Dice, do (Actions)
          • Loop - Actions
            • Set Dice_Roll[(Integer A)] = (Random integer number between 1 and 6)
            • Unit - Create 1 Rolled_Units[Dice_Roll[(Integer A)]] for (Triggering player) at (Center of Rolled_Region[(Integer A)]) facing Default building facing (270.0) degrees
      • Wait 0.75 seconds
      • Game - Display to (All players) for 30.00 seconds the text: ((Name of (Triggering player)) + (has rolled: |cffffcc00 + ((String(Dice_Roll[1])) + (|r, |cffffcc00 + ((String(Dice_Roll[2])) + (|r, |cffffcc00 + ((String(Dice_Roll[3])) + (|r, |cffffcc00 + ((String(Dice_Roll[4])) + (|r, |cffffcc00 + ((String(Dice_Roll[5]))
      • Game - Display to (All players) for 30.00 seconds the text: <Empty String>
        • Do Multiple ActionsFor each (Integer A) from 1 to Number_of_Dice, do (Actions)
          • Loop - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Dice_Roll[(Integer A)] Not equal to (!=) 1
              • Then - Actions
                • Set Not1 = True
              • Else - Actions
                • Set Not1 = False
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Dice_Roll[(Integer A)] Not equal to (!=) 5
              • Then - Actions
                • Set Not5 = True
              • Else - Actions
                • Set Not5 = False
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Dice_Roll[(Integer A)] Equal to (==) 2
              • Then - Actions
                • Set CounterOf2 = (CounterOf2 + 1)
              • Else - Actions
                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Dice_Roll[(Integer A)] Equal to (==) 3
                  • Then - Actions
                    • Set CounterOf3 = (CounterOf3 + 1)
                  • Else - Actions
                    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • Dice_Roll[(Integer A)] Equal to (==) 4
                      • Then - Actions
                        • Set CounterOf4 = (CounterOf4 + 1)
                      • Else - Actions
                        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • If - Conditions
                            • Dice_Roll[(Integer A)] Equal to (==) 6
                          • Then - Actions
                            • Set CounterOf6 = (CounterOf6 + 1)
                          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Not1 Equal to (==) True
            • Not5 Equal to (==) True
            • CounterOf2 Less than (<) 3
            • CounterOf3 Less than (<) 3
            • CounterOf4 Less than (<) 3
            • CounterOf6 Less than (<) 3
          • Then - Actions
            • Trigger - Run FARKLE <gen> (checking conditions)
            • Skip remaining actions
          • Else - Actions
      • Game - Display to (All players) for 30.00 seconds the text: ((Name of (Triggering player)) + now has 30 seconds to choose which dice they wish to keep.)
      • Trigger - Turn on Select to keep <gen>
      • Wait 30.00 seconds
      • Trigger - Turn off Select to keep <gen>
      • Game - Display to (All players) the text: ((Name of (Triggering player)) + has failed to select their dice in time. Next turn.)
So, if anyone can come up with a way to check this effectively and do what I want it to do, that would be great. Of course, rep and credits shall be awarded.
 
First for the straight... add this on the Integer A loop
This will make the IsStraight false on the first instance that a Number is rolled more than once hence a straight is already not possible
  • Set IsStraight equal to true
  • For each integerB from 1 to Integer A
    • Do - Actions
      • If-Then-Else
        • If - Conditions
          • Dice_Roll[Integer B] is equal to Dice_Roll[Integer A]
        • Then - Actions
          • Set IsStright to false
Now for the removal thingy... it would require lots of If-then-elses...
To be put AFTER the first Integer loop where you roll the die
Example:
  • THIS LOOP
  • Set AllScoringDice[PlayerNumberofOwnerOfTriggeringUnit] equal to true
  • For Each integerA from 1 to 6
    • Do - Actions
      • If-Then-Else
        • If - Conditons
          • Dice_Roll[Integer A] is equal to 2
        • Then - Actions
          • If-Then-Else
            • If - Conditions
              • Or - Any condition is true
                • CounterOf2 is greater than 2
                • IsStraight is equal to true
            • Then - Actions
            • Else - Actions
              • You remove the dice
              • Set AllScoringDice[PlayerNumberofOwnerOfTriggeringUnit] equal to false
now just copy that if-then-else and paste it INSIDE that integerA loop(THIS LOOP) and modify it for the numbers 3,4,6

and at the start of the Re-Roll trigger, just check if AllScoringDice[PlayerNumberofOwnerOfTriggeringUnit] is true + NumberOfHeldDice thingy
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
What's your obsession with [PlayerNumberofOwnerOfTriggeringUnit] ? lol. It still doesn't make sense to me to use that (And I haven't yet)
 
What's your obsession with [PlayerNumberofOwnerOfTriggeringUnit] ? lol. It still doesn't make sense to me to use that (And I haven't yet)

to save the values specifically to each player... have you tried the ReRoll yet? I think it could bug because of Run - Trigger... its better if you just combine the ReRoll and Roll triggers... Coz I always see to it to make it MUI or at least MPI (like in that case)...
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
Well, I was planning on running a trigger on changing turns, in which i set all the values to zero again, that way that doesn't have issues. I gotta make the trigger to switch players anyway, so may as well do it all in one go there, ^^
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
Good to know... um...I guess i'll have to fiddle with the object editor again (Eww. I hate it more than trigger editor ><).

I thought maybe that would work, though since the event was the same. same unit, same ability everything, but the more i think about it, the less i believe

EDIT: lol spelling. hard to type with the laptop on my chest.
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
hmm, I guess.

Don't wanna cross the room to the desktop to work though. I'm cozy in bed. :D

Gonna get some sleep tonight since I didn't get much this morning, xD

I'll try and fix it up in the morn'
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
NVM. Not solved. It's happening still.

Okay, I didn't go in and fix the other problem yet, cause I found another issue when I was finishing up the trigger.

It's only supposed to farkle if there is NO 1's, NO 5's, less than THREE (3) of any other number.

This appears to not be the case, as when I was testing it, this happened when I clearly had a 1 on the board (Although it did remove everything and the rest of the farkle trigger seemed to work quite nicely).

attachment.php
FarkleFail.jpg


As you see, there's clearly a 1. But it still Farkled. Here's the triggers in question:

The roll trigger. This is where it checks the values.
  • Roll Dice
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (==) Roll Dice
    • Actions
      • Trigger - Turn off (This trigger)
        • Do Multiple ActionsFor each (Integer A) from 1 to Number_of_Dice, do (Actions)
          • Loop - Actions
            • Set Dice_Roll[(Integer A)] = (Random integer number between 1 and 6)
            • Unit - Create 1 Rolled_Units[Dice_Roll[(Integer A)]] for (Triggering player) at (Center of Rolled_Region[(Integer A)]) facing Default building facing (270.0) degrees
      • Wait 0.75 seconds
      • Game - Display to (All players) for 30.00 seconds the text: ((Name of (Triggering player)) + (has rolled: |cffffcc00 + ((String(Dice_Roll[1])) + (|r, |cffffcc00 + ((String(Dice_Roll[2])) + (|r, |cffffcc00 + ((String(Dice_Roll[3])) + (|r, |cffffcc00 + ((String(Dice_Roll[4])) + (|r, |cffffcc00 + ((String(Dice_Roll[5]))
      • Game - Display to (All players) for 30.00 seconds the text: <Empty String>
        • Do Multiple ActionsFor each (Integer A) from 1 to Number_of_Dice, do (Actions)
          • Loop - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Dice_Roll[(Integer A)] Not equal to (!=) 1
              • Then - Actions
                • Set Not1 = True
              • Else - Actions
                • Set Not1 = False
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Dice_Roll[(Integer A)] Not equal to (!=) 5
              • Then - Actions
                • Set Not5 = True
              • Else - Actions
                • Set Not5 = False
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Dice_Roll[(Integer A)] Equal to (==) 2
              • Then - Actions
                • Set CounterOf2 = (CounterOf2 + 1)
              • Else - Actions
                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Dice_Roll[(Integer A)] Equal to (==) 3
                  • Then - Actions
                    • Set CounterOf3 = (CounterOf3 + 1)
                  • Else - Actions
                    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • Dice_Roll[(Integer A)] Equal to (==) 4
                      • Then - Actions
                        • Set CounterOf4 = (CounterOf4 + 1)
                      • Else - Actions
                        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • If - Conditions
                            • Dice_Roll[(Integer A)] Equal to (==) 6
                          • Then - Actions
                            • Set CounterOf6 = (CounterOf6 + 1)
                          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Not1 Equal to (==) True
            • Not5 Equal to (==) True
            • CounterOf2 Less than (<) 3
            • CounterOf3 Less than (<) 3
            • CounterOf4 Less than (<) 3
            • CounterOf6 Less than (<) 3
          • Then - Actions
            • Trigger - Run FARKLE <gen> (checking conditions)
            • Skip remaining actions
          • Else - Actions
      • Game - Display to (All players) for 30.00 seconds the text: ((Name of (Triggering player)) + now has 30 seconds to choose which dice they wish to keep.)
      • Trigger - Turn on Select to keep <gen>
      • Wait 30.00 seconds
      • Trigger - Turn off Select to keep <gen>
      • Game - Display to (All players) the text: ((Name of (Triggering player)) + has failed to select their dice in time. Next turn.)
The farkle (Fail) trigger.
  • FARKLE
    • Events
    • Conditions
    • Actions
      • Set Temp_Score = 0
      • Set TempGroup_AllDice = (Units in All Dice <gen>)
      • Game - Display to (All players) the text: ((Name of (Triggering player)) + has FARKLED! Their points for this round will return to 0, and the next turn will start.)
      • Unit Group - Pick every unit in TempGroup_AllDice and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Custom script: call DestroyGroup(udg_TempGroup_AllDice)
      • Wait 0.50 seconds
      • Trigger - Run Next Player <gen> (checking conditions)
An idea hit me, I thought maybe if I put the list of conditions in an AND function... yeah didn't work. Tried again, got 5, 1, 3, 5, 6, 3. Didn't work. =\
The other idea I had was maybe it was dependant on the first number being a 1 or 5. But this also crushes that idea. With a 1 and 2 5s it doesn't work, but that's a scoring throw, there.
 
Last edited:
its because of the way the conds are set-up in the loop

example: the first one

  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Dice_Roll[(Integer A)] Not equal to (!=) 1
      • Then - Actions
        • Set Not1 = True
      • Else - Actions
        • Set Not1 = False
if, the first die is 1, then Not1 will be false

now if a second,third, etc die is not 1 then Not1 will be equal to true...

which causes a bug...

now do this to solve... Set Not1 and Not5 to true before the loop, now if Not1 or Not5 becomes false, do not change that value anymore... basically remove the action which set's it to true from the loop and put it before the loop


  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Dice_Roll[(Integer A)] Not equal to (!=) 1
      • Then - Actions
      • Else - Actions
        • Set Not1 = False
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
Oh, I see. I didn't realize that would happen. Thanks again.

So, now to get the reroll to work. I think I'm gonna end up making another ability named Reroll or something, I'm not sure how I'm gonna do it yet, since it indeed doesn't work on the reroll currently.
 
Status
Not open for further replies.
Top