Random Unit Creation

vi3tbomba

New Member
Reaction score
0
:banghead: Ok, I edited this one but here is what I'm trying to do.

Set RandomChance = (Random integer between 1 and 100)

If RandomChance = 1 to 25
Then Create Footman

If RandomChance = 26 to 50
Then Create Archer

If Tier_RandomUnit = 50 to 100
Then Create Peon

So there is a 25% chance that it will create a Footman or an Archer and a 50% chance to create a Peon.
But, how do I make it where once a Footman is created, RandomChance is rolled again but it cannot roll 1 to 25; therefore, creating a Footman will not happen.

Thanks for any help on this one.
 

Weegee

Go Weegee!
Reaction score
102
well you could have an int with an array that sets the random number into the array. Then when the random int fires check if it was the same int as any of the ones before. If it IS then just tell it to redo it. Might require some hard triggering though :D
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Put all unit types in an array (at map init for example):

Set Units[1] = this unit
Set Units[2] = that unit
Set Units[3] = some unit
Set Units[4] = other unit

Some integer that tells you how many you have:

Set Count = 4


And, when you need one:

Set TempInteger = Random integer between 1 and Count
Unit - Create 1 Units[TempInteger] at <somewhere> for <someone> facing default
Set Units[TempInteger] = Units[Count]
Set Count = Count - 1

This can run as often as you have units in that array. No repeats.
 

vi3tbomba

New Member
Reaction score
0
Random Unit Created of One Type

Ok, here is what I'm trying to do.

Set RandomChance = (Random integer between 1 and 100)

If RandomChance = 1 to 25
Then Create Footman

If RandomChance = 26 to 50
Then Create Archer

If Tier_RandomUnit = 50 to 100
Then Create Peon

So there is a 25% chance that it will create a Footman or an Archer and a 50% chance to create a Peon.
But, how do I make it where once a Footman is created, RandomChance is rolled again but it cannot roll 1 to 25; therefore, creating a Footman will not happen.

Thanks for any help on this one.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top