• 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.

random hints

Status
Not open for further replies.
Level 8
Joined
Jul 7, 2013
Messages
141
Something like this?

  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set string_var[1] = blabla
      • Set string_var[2] = blabla
      • Set string_var[3] = blabla
      • Set string_var[4] = blabla
      • Set string_var[5] = blabla
      • Set string_int = 5
  • Periodic Hint
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Game - Display to (All players) the text: string_var[(Random integer number between 1 and string_int)]
string_var are your hints
string_int is the total number of hints
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
You should also use less random, random hints.

Set all messages to a string array. Pick a random index from the array (random integer) for a random hint. Keep track of the last hint and if it gets chosen again you try to roll again (up to a maximum of X times to prevent possible thread crash).
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
Alternatively, you could get X messages and choose random message between 1 and (X-1). Then swap that chosen message with last message in the list. That will prevent showing same messages as well.

e.g. 5 messages, so you choose random message between 1 and 4. Say message 3 has been chosen, then show that message and swap it with message 5. Now message 5 text is saved as Message3 and vice versa.
 
Alternatively, you could get X messages and choose random message between 1 and (X-1). Then swap that chosen message with last message in the list. That will prevent showing same messages as well.

e.g. 5 messages, so you choose random message between 1 and 4. Say message 3 has been chosen, then show that message and swap it with message 5. Now message 5 text is saved as Message3 and vice versa.

the problem with this is the same 2 messages can be shown over and over again.
 
ya i know what you mean it's just more complicated than you posted.

basically you store all hints from lets say 1 to 10.

then you have an integer array thats empty and an integer array with integers from 1 to 10 and a max index integer

you then use a loop to store the integers from the integer array with integers into the empty integer array and de-index the old integer.
then you use the old array that used to be empty as the index for the hint.
 
Status
Not open for further replies.
Top