• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Creating random hints like in other games?

Status
Not open for further replies.
Level 17
Joined
Feb 11, 2011
Messages
1,860
1. Open the variable editor and create a string array.
2. Create a trigger that runs on map initialization. Set each of the array elements to a hint. For example:
  • Set RandomHint[0] = |cffffcc00Hint|r: This map was made by Allain55X!
  • Set RandomHint[1] = |cffffcc00Hint|r: Visit the HiveWorkshop.com for more cool things.
3. Create another trigger that runs every X seconds. You would do something like this:
  • Trigger
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • Game - Display to (All players) the text: RandomHint[(Random integer number between 0 and 5)]
You would change the 5 in "(Random integer number between 0 and 5)" to the highest array element (total amount of hints).
 
Level 4
Joined
Jun 2, 2012
Messages
747
1. Open the variable editor and create a string array.
2. Create a trigger that runs on map initialization. Set each of the array elements to a hint. For example:
  • Set RandomHint[0] = This map was made by Allain55X!
  • Set RandomHint[1] = Visit the HiveWorkshop.com for more cool things.
3. Create another trigger that runs every X seconds. You would do something like this:
  • Trigger
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • Game - Display to (All players) the text: RandomHint[(Random integer number between 0 and 5)]
You would change the 5 in "(Random integer number between 0 and 5)" to the highest array element (total amount of hints).

TY mR.Bean very helpful! +REP!:thumbs_up:
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Here's a simple method so that you don't get the same message twice. When all messages have been displayed, it then resets the list and displays them in random order.

  • Untitled Trigger 014
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set new[0] = 1
      • Set new[1] = 2
      • Set new[2] = 3
      • Set new[3] = 4
      • // 3 is the index of the last hint
      • For each (Integer A) from 0 to 3, do (Actions)
        • Loop - Actions
          • Set new[(1000 + (Integer A))] = new[(Integer A)]
      • Set i1 = 3
  • Untitled Trigger 018
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Set i = (Random integer number between 0 and i1)
      • // Use hint message instead of Game - display...
      • Game - Display to Player Group - Player 1 (Red) the text: new[i]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • i1 Equal to 0
        • Then - Actions
          • For each (Integer A) from 0 to 3, do (Actions)
            • Loop - Actions
              • Set new[(Integer A)] = new[(1000 + (Integer A))]
          • Set i1 = 3
        • Else - Actions
          • Set new[i] = new[i1]
          • Set i1 = (i1 - 1)
I used poor variable names, you can use some better ones.
 
Level 4
Joined
Jun 2, 2012
Messages
747
Here's a simple method so that you don't get the same message twice. When all messages have been displayed, it then resets the list and displays them in random order.

  • Untitled Trigger 014
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set new[0] = 1
      • Set new[1] = 2
      • Set new[2] = 3
      • Set new[3] = 4
      • // 3 is the index of the last hint
      • For each (Integer A) from 0 to 3, do (Actions)
        • Loop - Actions
          • Set new[(1000 + (Integer A))] = new[(Integer A)]
      • Set i1 = 3
  • Untitled Trigger 018
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Set i = (Random integer number between 0 and i1)
      • // Use hint message instead of Game - display...
      • Game - Display to Player Group - Player 1 (Red) the text: new[i]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • i1 Equal to 0
        • Then - Actions
          • For each (Integer A) from 0 to 3, do (Actions)
            • Loop - Actions
              • Set new[(Integer A)] = new[(1000 + (Integer A))]
          • Set i1 = 3
        • Else - Actions
          • Set new[i] = new[i1]
          • Set i1 = (i1 - 1)
I used poor variable names, you can use some better ones.

I think Mr Bean's tutorial is more easier but thanks for the help +REP!
 
Status
Not open for further replies.
Top