Random towers for builder?

zzyzxroad

TH.net Regular
Reaction score
1
I was wondering if it was possible that a builder does't just have the same towers, but if it could be coded that the builder would receive a couple of towers randomly.

So if there were basic, normal and advanced towers:


A B C D E (Basic)
F G H I J (Normal)
K L M N O (Advanced)

He could get something like this as his "structures built":

B D E
F I J
K M O
 

Juggernaut

I don't know what to change it to
Reaction score
33
add the spells in arrays such as ( towerbasic [1],towerbasic[2] etc. towernormal[1],towernormal[2] etc. toweradvanced[1],toweradvanced[2] etc)
then when you want to add the towers.
Select 1 random number from 1 to total number of basic/advanced towers.
for each tower type you select 1 random number.

e.g random number from 1 to NumberOfBasicTowers, // this is the total number of towers available of this type.
random number from 1 to NumberOfNormalTowers,
random number from 1 to NumberOfAdvancedTowers,

then use Unit - Add ability and add towerbasic[The random number you picked before]
Do this for all the tower types.
 

thorhunter

You can change this now in User CP.
Reaction score
32
If your map considers one builder per player you can add all possible towers to a builder and then 'set max units available for player' for disabled towers to 0.
 

zzyzxroad

TH.net Regular
Reaction score
1
Thanks for the replies. I will have to mull over the answers to see if any are possible, and if I can figure it out in WE. ;) (Havnt coded in years)

What I am doing, is creating a random race from several existing races. I want the triggers to pull the towers from those existing races randomly and insert them into this one race. All players actually get 2 builders, but I don't know if thorhunter's ide will work.
 

Solu9

You can change this now in User CP.
Reaction score
216
Lets say you have 3 different kinds of towers. In the example I'll be using Defensive, Offensive and Support.

Make an ability array for each of the three categories. Fx:
Defensive_Array:
Set Defensive_Array [1] = Tower A
Set Defensive_Array [2] = Tower B
Set Defensive_Array [3] = Tower C
Set Defensive_Array [4] = Tower D

When the unit is acquired run this trigger:

Events - Whatever you want
Conditions - Whatever you want
Actions -
Add Defensive_Array [Random integer number between 1 and 4] to "your unit"
Add Offensive_Array [Random integer number between 1 and 4] to "your unit"
Add Support_Array [Random integer number between 1 and 4] to "your unit"

If you want more towers from the same category just add in a condition to check if the unit already has the picked tower.

Edit: So basically I just said what Juggernaut said, great.
 

zzyzxroad

TH.net Regular
Reaction score
1
Edit: So basically I just said what Juggernaut said, great.

But yours was easier to understand, especially since I am getting back into after 3 years away. :D

Thanks. Will try it after work.

EDIT:
Ok, so I have been trying to set up these towers as you guys are describing, and it is not quite working. How can I set up a tower as an ABILITY, when it is a UNIT?
I was never the best coder as it was, but after 3 years I think I forgot most everything, so sorry if I seem a little stunned :confused:
 

zzyzxroad

TH.net Regular
Reaction score
1
Well it's been a loooong time. Thought i would give it a try, and still no-go. I uploaded the test map. It's a TD just so I don't have to do all the Terrain and spawns.

Maybe someone can take a look and see where the hell I might be going wrong.


Thanks.
 

Attachments

  • TestMap for random 2.w3x
    95.8 KB · Views: 246

Solu9

You can change this now in User CP.
Reaction score
216
Base the towers on the "Build Tiny Farm (or any other)" ability.
Set the ability to a unit ability instead of item ability.

Add the ability to the unit via triggers like the original answers describe.

Edit:
I didn't look at the map btw.
 

zzyzxroad

TH.net Regular
Reaction score
1
Late reply. I finally have it working. First I had to add ALL the towers to my builder. I used a trigger to make these towers unavailable. Then I used your examples to write the rest to add 11 various towers for him to be able to be built.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top