Hello everyone. How to:
- Create an array (or structure) with 5 referenced enemies (say for example: enemy1, enemy2, etc.).
- Randomly select an enemy every 2 seconds from the array according to this rule: a grand round of 10 selections where all enemies can be selected twice. Here’s a concrete example:
1st round of selection: Enemy 4
2nd: Enemy 2
3rd: Enemy 4
4th: Enemy 3
5th: Enemy 1
6th: Enemy 5
7th: Enemy 3
8th: Enemy 2
9th: Enemy 5
10th: Enemy 1
Then we start a general round again (two instances of each enemy type over 10 rounds).
This next phase would therefore not be possible:
1st round of selection: Enemy 4
2nd: Enemy 5
3rd: Enemy 4
4th: Enemy 1
5th: Enemy 4 ----3 instances of Enemy 4 have been selected in the 10 rounds.
- Then create the selected enemy at the spawn.X spawn.Y points each time.
The random selection stops when a maximum of 15 enemies have been selected.
1 Like
Thanks for the information on how to do this, but honestly I have a hard time understanding a lot of things with arrays. For example: I don’t know how to create an object based on the value of an array, whether it’s numeric or text. I haven’t seen the concept of “reading an array in order” with the Array Tools extension or how to do that, or how to shuffle the array when it reaches the end.
You should simply understand that an array is like a structure just that it’s numbered starting from 0 by the engine automatically.
For creating an object base on the value of array will be like
Get random value from array, if value is equal to X create enemy Y.
Arrays can’t store objects and you can use text, numbers or booleans to create an object even if the value is equals to the object name.
So I prefer you used a simple approach:
-
Fill an array with random numbers between 1-5 ( or you can use enemy1 - enemy5 ). You can use a simple repeat controlled by a local variable
-
After this you do another repeat for each child in the array, at each repeat of the value is equals to 1 then create the desired object.
-
Get