• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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,204
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 25
Joined
Sep 26, 2009
Messages
2,387
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.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
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.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
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