• 🏆 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 to make chances to do things

Level 12
Joined
Mar 10, 2008
Messages
869
This tutorial is about making things have a chance to happen. You can do this in GUI triggers. First you need your Integer Variable. Lets name it Chance.

Now, make a trigger:
  • Chance Randomization
    • Events
      • Time - Every 3 seconds of game time
    • Conditions
    • Actions
      • Set Chance = 0
      • Wait 1 second
      • Set Chance = 1
      • Wait 1 second
      • Set Chance = 2
      • Wait 1 second
This is your randomizer.
You can set intervals to different times but make sure the total adds up to the event.
Now lets see how it works.

  • Chance Example
    • Events
      • -Whatever you want happens-
    • Conditions
    • Actions
      • If (Chance Equal to 0) then do (Game - Display to (All Players) the text: Lol) else do (Do nothing)
      • If (Chance Equal to 1) then do (Game - Display to (All Players) the text: Rofl) else do (Do nothing)
      • If (Chance Equal to 2) then do (Game - Display to (All Players) the text: Lmao) else do (Do nothing)
With this you can make the chat say different possible things instead of it repeating itself.
You can do almost anything in GUI randomized with this.

Hope you like my TUT.
 
Last edited:
Level 10
Joined
Jun 1, 2008
Messages
485
ok, basic and simple tutorial. you could change the action of Chance Randomization to like this
  • For each (Integer A) from 1 to 10, do (Actions)
    • Loop - Actions
      • Set Chance = (Integer A)
      • Wait 1.00 seconds
just to make it more easy and simple or even more efficient.

And, why use chance randomizer when you can use this:
  • Set Chance = (Random integer number between 1 and 10)
it's more simple, but it have it's own formula, but harder to see it formula than your randomizer.
 
Level 19
Joined
Nov 16, 2006
Messages
2,165
You don't even need that variable.
Even more easier to do (+ its one trigger!) :
  • 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: bleh
    • Else - 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: meh
        • Else - Actions
          • Game - Display to (All players) the text: the fek?
This will randomize something too.
 
Level 31
Joined
May 3, 2008
Messages
3,155
Your technique is not the best. It isn't not only ineffective, but it have lot's of flaw. If you want thing such as game text to appear randomly, the best way to make it would be like this.

This trigger was part of the trigger of my map "Click To Kill".

  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Hint[1] = You will lose 1 lives if a Acolyte is killed.
      • Set Hint[2] = Naga Myrmidon will grant you additional five lives if it is killed.
      • Set Hint[3] = If a Wisp is killed, every Orc will be killed as well.
      • Set Hint[4] = You will lose 3 lives if a Ghoul is killed.
      • Set Hint[5] = You will lose 5 lives if a Abomination is killed.
      • Set Hint[6] = Once your scores exceed 300, the difficulty would increase.
      • Set Hint[7] = Once your scores exceed 500, a Blademaster would arrive. Do not worry, he only spawn once.
      • Set Hint[8] = Kill Orc hero would give you 10 scores.
      • Set Hint[9] = Kill Human unit would resulted into score deduction.
      • Set Hint[10] = If your score goes below 300, the difficulty would be back to normal as long as you do not achieve 700 scores and above.
      • Set Hint[11] = Raider and Fel Orc Raider are the hardest to kill.
      • Set Hint[12] = Chaos Orc are harder to kill, but they give additional 1 point.
      • Set Hint[13] = If your score exceed 700, weaker orc unit such as peon would no longer be available.
      • Set Hint[14] = If your score exceed 700, unit would respawn much quicker.
      • Set Hint[15] = If your score exceed 700, the only undead unit that would appear is Abomination.
      • Set Hint[16] = You will lose 3 points if a Peasant is killed
      • Set Hint[17] = You will lose 7 points if a Footman is killed
      • Set Hint[18] = You will lose 15 points if a Knight is killed
      • Set Hint[19] = If your score exceed 900, the only orc unit available would be Raider and Fel Orc Raider.
      • Set Hint[20] = In order to reach Impossible stage, you must rake a score of 1,500.
      • Set Hint[21] = The only Orc unit available at Impossible stage is Drak'thul.
      • Set Hint[22] = At Impossible Stage, killing a human or undead unit could resulted into heavy loss.
      • Set Hint[23] = Wisp and Naga Myrmidon are not available at Impossible stage.
      • Set Hint[24] = Demon would kill Undead & Human unit only. This would resulted into lives and score deduction, be on the lookout.
      • Set Hint[25] = Nothing would happen if a Demon was killed.
  • Message
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Game - Display to (All players) for 30.00 seconds the text: (|cFF008000Hint|r - + Hint[(Random integer number between 1 and 25)])
      • Sound - Play Hint <gen>
Work better and efficient compare to the 1 you post. Why?

  • Chance Randomization
    • Events
      • Time - Every 3 seconds of game time
    • Conditions
    • Actions
      • Set Chance = 0
      • Wait 1 second
      • Set Chance = 1
      • Wait 1 second
      • Set Chance = 2
      • Wait 1 second
  • Chance Example
    • Events
      • Time - Every 3.00 seconds of game time
    • Conditions
    • Actions
      • If (Chance Equal to 0) then do (Game - Display to (All Players) the text: Lol) else do (Do nothing)
      • If (Chance Equal to 1) then do (Game - Display to (All Players) the text: Rofl) else do (Do nothing)
      • If (Chance Equal to 2) then do (Game - Display to (All Players) the text: Lmao) else do (Do nothing)
If I set it according to this way, can you guess what happen? The gametext would only display the message of integer 1 or 2 since the wait action would eventually be consisten with the action time.
 
Level 34
Joined
Sep 6, 2006
Messages
8,873
If you want help, please post in the World Editor Help Zone. This tutorial has been proven to be ineffective.

~Sent to Graveyard~
 
Top