creating random waves (order)

MissKerrigan

Active Member
Reaction score
23
Hello,

- I got 9 towers in my tower defense

- marine
- stalker
- hydralisk
- marauder
- templar
- roach
- vulture
- immortal
- queen

Because of this, there are also 9 different wave tpyes (the same 9 units)
The marine shoots 75% damage to marine, the stalker 75% damage to stalker etc...
But that doesn't matter now


What I want to ask are 2 things

1. How do I create only the waves which are the available towers?

(in the start the players can only make marines - stalkers - hydralisks, so only this 3 units must appear as wave)


2. How do I create the waves randomly?

NOTE: if the first wave are the marines, then the next wave must be hydralisk or stalker, at last the wave which hasn't appeared yet must come, and after that the 3 wave types must come again randomly


(later in game when the player can build about 7 towers, there must come 7 different waves)

I tried to create a variable of an array size of 9 but I don't know how to create the units which are only available yet

Marloes
 

Dave312

Censored for your safe viewing
Reaction score
269
This is not very straight forward to do. You are on the right track by creating a variable array of size 9 (set the variable type to Unit Type). The best way to do this would be to create a custom function which returns the unit type for the wave. Create the following global variables:

- WaveUnits (variable type Unit Type, array of size 9)
- ArrayLength (variable type integer, set the default value to 0)

The WaveUnits variable is the variable you have already created. The ArrayLength variable just determines how many units are stored in the array. Once you have created these variables, create the following custom function (Ctrl+Alt+F):
Trigger:
  • GetRandomWaveUnit
    • Options: Function
    • Return Type: Game Link - Unit
    • Parameters
    • Grammar Text: GetRandomWaveUnit()
    • Hint Text: (None)
    • Custom Script Code
    • Local Variables
      • i = 0 <Integer>
      • Unit = No Game Link <Game Link - Unit>
      • UnitIndex = 0 <Integer>
    • Actions
      • ------- Check if there are no units in the array, if none add every available unit to the array
      • General - If (Conditions) then do (Actions) else do (Actions)
        • If
          • ArraySize == 0
        • Then
          • Variable - Set WaveUnits[0] = Marine
          • Variable - Set WaveUnits[1] = Stalker
          • Variable - Set WaveUnits[2] = Hydralisk
          • Variable - Set ArraySize = 3
          • ------- Check if Marauder is available
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • //Marauder Unit is Available
            • Then
              • Variable - Set WaveUnits[3] = Marauder
              • Variable - Modify ArraySize: + 1
            • Else
          • ------- Check if Templar is available
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • //Templar Unit is Available
            • Then
              • Variable - Set WaveUnits[4] = High Templar
              • Variable - Modify ArraySize: + 1
            • Else
          • ------- Check if the other units are available and add them to the array as per above
        • Else
      • ------- Select a random unit from the array
      • Variable - Set UnitIndex = (Random integer between 0 and (ArraySize - 1))
      • Variable - Set Unit = WaveUnits[UnitIndex]
      • ------- Remove selected unit from the array
      • General - For each integer i from UnitIndex to 8 with increment 1, do (Actions)
        • Actions
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • i < 8
            • Then
              • Variable - Set WaveUnits<i> = WaveUnits[(i + 1)]
            • Else
              • Variable - Set WaveUnits<i> = No Game Link
      • Variable - Modify ArraySize: - 1
    • </i></i>


Now when you want to work out what your next wave should be, just call this function:
Code:
Variable - Set NextWave = GetRandomWaveUnit()
 

MissKerrigan

Active Member
Reaction score
23
woow, I didn't expected this haha, it hurts my eyes when I analize it

would it easier if I create it like this?


- in start there are only 3 units available: marine stalker hydralisk
- so I create a trigger that brings a marine wave, then a stalker wave and at last a hydralisk wave
- the only thing I want to know how to add unlocked units to the wave-spawn-group
 

Dave312

Censored for your safe viewing
Reaction score
269
I suppose you could, but it wouldn't be random like you wanted and it would be the same amount of work if not more (your trigger would probably look much the same as the one I posted too).

I'm sure the trigger looks rather complicated, but really it isn't. And the concept of using functions is probably something you should learn if you want to create complex things. They can also make your triggers look much simpler and easier to read. I recommend you just try making it and if you get stuck, you can always ask for some help.
 

MissKerrigan

Active Member
Reaction score
23
I believe very well if you say the trigger is about the same size, I'm gonna read your post till I understand it haha THANKS
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top