• 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.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Random unit spawn system and HP scaling

Status
Not open for further replies.
Level 14
Joined
Nov 4, 2006
Messages
1,241
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 29
Joined
Nov 18, 2012
Messages
2,014
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 14
Joined
Nov 4, 2006
Messages
1,241
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