• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Random unit spawn system and HP scaling

Status
Not open for further replies.
Level 13
Joined
Nov 4, 2006
Messages
1,239
Hi everyone,

1)
i'm looking for a good way to create a random unit spawn trigger.

Setup is as follows:

i have 5 levels and 3 different unit types (A B C)

now obviously 2 of the units will spawn twice within the 5 waves, but they should not be allowed to spawn three times, back to back is allowed, so e.g.
AABCB
ABCAB
ACCBA
...

the way i thought of doing it is creating an integer array for the three starting at "2" and decreasing it by 1 every time they spawn and then loop through the options until i hit one that's not 0, but that seems somewhat inefficient (or maybe i'm doing it wrong). Is there a better way to do that? GUI is strongly preferred unless it's a full system i can copy.

2)
to avoid having to create 3x5 units, i just create 1 of each type and adjust their HP by modifying the player handicap each level. any other ideas on that or is this the best way to do that?
 

Wrda

Spell Reviewer
Level 25
Joined
Nov 18, 2012
Messages
1,870
Have an integer array like this:
set List[1] = 1
set List[2] = 1
set List[3] = 2
set List[4] = 2
set List[5] = 3
set List[6] = 3
The values act as if they're unit types.
Then you'd have a variable to take a random value between 1 and max index of the list (6)
then use List[random value] for the creation, and remove the index by
set List[the random value] = MaxIndex
set MaxIndex = MaxIndex - 1
 
Level 13
Joined
Nov 4, 2006
Messages
1,239
i don't get it sry, from what i understand the following happens:

Then you'd have a variable to take a random value between 1 and max index of the list (6) -> let's say 4

then use List[random value] for the creation, and remove the index by -> List[4] = 2, so i create a unit of type 2

set List[the random value] = MaxIndex -> so List[4] = 6 ??

set MaxIndex = MaxIndex - 1 -> so next time i only check from 1-5 in a list that looks like this:
List[1] = 1
List[2] = 1
List[3] = 2
List[4] = 6
List[5] = 3
(List[6] = 3) this value will be ignored since maxindex is now 5 and if 4 get's rolled again no unit will spawn since 6 is not defined

i think i misunderstood sth here
 
Status
Not open for further replies.
Top