• 🏆 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!

[Solved] How to create random pick system? Details inside.

Level 17
Joined
Jun 2, 2009
Messages
1,184
Hello. I am going to ask for whole system this time. Here is the example.

You have 5 integers.
Game selects randomly 3 of the integers and sorts.
Same integer cannot be selected more than once.

Example

Game picked numbers 1, 3 and 4.
The trigger with number 1 runs, then runs 3 and runs 4.
 
Level 17
Joined
Jun 2, 2009
Messages
1,184
It would be best. Because he already knows i will never get it. No one tried to spent time for explain, i have learned how to do what i want
Problem solved, everyone happy :)
If i was capable to understand and wanted to learn about this system, probably i have already asked for details and explanation.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,232
The basic idea is to create a set of numbers, such as an array set. Then pick a random element from that set, removing it in the process. These picked elements then are stored in a list, such as an array list. Repeat until you picked the number of elements desired. Then you can sort the list using any sorting algorithm, such as linear sort.

The use of a set to store the numbers to pick from allows an optimisation for removal if implemented using an array. The removed element can be replaced with the last element. If an array list was used then all subsequent elements have to be moved down 1 place.
 
Top